package com.cdp.system.service.impl;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cdp.common.core.domain.AjaxResult;
import com.cdp.common.core.domain.entity.*;
import com.cdp.common.utils.SecurityUtils;
import com.cdp.common.utils.StringUtils;
import com.cdp.common.utils.poi.ExcelUtil;
import com.cdp.common.utils.uuid.IdUtils;
import com.cdp.system.dto.AuditRequestDTO;
import com.cdp.system.dto.FileAuditDTO;
import com.cdp.system.dto.SaveDataDTO;
import com.cdp.system.mapper.SysCementMapper;
import com.cdp.system.mapper.SysFlyashMapper;
import com.cdp.system.mapper.SysRegionMapper;
import com.cdp.system.mapper.sysFileAuditMapper;
import com.cdp.system.service.*;
import com.cdp.system.vo.SysMechanicalPerformanceFourthVO;
import com.cdp.system.vo.SysMechanicalPerformanceThirdVO;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.Timestamp;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;

import static org.apache.logging.log4j.util.Strings.isBlank;

@Service
public class SysFileAuditServiceImpl extends ServiceImpl<sysFileAuditMapper, SysFileAudit> implements ISysFileAuditService {

    @Value("${file.excel-mechanical-performance}")
    private String mechanicalPerformanceExcelPath;
    @Autowired
    private SysMaterialSlumpUrlService sysMaterialSlumpUrlService;
    @Autowired
    private sysFileAuditMapper sysFileAuditMapper;
    @Autowired
    private ISysEfficiencyAgentService sysEfficiencyAgent;
    @Autowired
    private RegionServiceImpl regionService;
    @Autowired
    private ISysFlyashService sysFlyashService;
    @Autowired
    private SysFlyashMapper sysFlyashMapper;
    @Autowired
    private SysCementMapper sysCementMapper;
    @Autowired
    private ISysCementService sysCementService;

    @Autowired
    private ISysSandService sysSandService;

    @Autowired
    private ISysStoneService sysStoneService;

    @Autowired
    private SysRegionMapper sysRegionMapper;


    @Autowired
    private SysOtherAdmixturesService sysOtherAdmixturesService;

    @Autowired
    private ISysMineralPowderService sysMineralPowderService;

    @Autowired
    private ISysWaterReducerService sysWaterReducerService;

    @Autowired
    private ISysEfficiencyAgentService sysEfficiencyAgentService;


    @Autowired
    private ISysSwellingagentService sysSwellingagentService;
    @Autowired
    private ISysMechanicalPerformanceService sysMechanicalPerformanceService;


    @Autowired
    private ISysSlumpService sysSlumpService;
    @Autowired
    private ISysFileAuditService sysFileAuditService;

    // 读取文件保存路径
    @Value("${file.upload-dir}")
    private String uploadDir;


    /**
     * 中间表
     * 测试用
     *
     * @return
     */
    @Override
    public List<SysFileAudit> listFileAudits() {

        List<SysFileAudit> list = sysFileAuditMapper.listFileAudits();
        return list;
    }

//  1： 水泥
//  2： 砂
//  3： 石
//  4： 粉煤灰
//  5： 减水剂
//  6： 增效剂
//  7：力学性能
//  8：变形性能
//  9：耐久性能


    /**
     * 保存到文件到服务器
     *
     * @param saveDataDTO
     * @return
     */
    @Override
    @Transactional
    public AjaxResult processAndSaveData(SaveDataDTO saveDataDTO) {
        // 新加的用户显示用New
        String rawFilePath = saveDataToFileV1(saveDataDTO.getData(), saveDataDTO.getFileName());

        //校验
        AjaxResult validationResult = validateInput(saveDataDTO);
        if (!validationResult.isSuccess()) {
            return validationResult;
        }

        // 2.保存json到服务器 返回的是文件路径
        String filePath = saveDataToFile(saveDataDTO.getData(), saveDataDTO.getFileName());

        // 3. 保存文件路径和文件名称到审核表中待审核
        Integer id = saveFilsJson(filePath,rawFilePath, saveDataDTO.getTableName(), saveDataDTO.getFileName());
        HashMap<Object, Object> map = new HashMap<>();
        map.put("id", id);

        // 4. 返回成功响应
        return AjaxResult.success(map);
    }
    private String saveDataToFile(List<List<String>> data, String baseFileName) {
        // 生成唯一文件名：毫秒时间戳 + 3位随机数字
        String timestamp = String.valueOf(System.currentTimeMillis());
        String randomSuffix = String.format("%03d", new Random().nextInt(1000));
        String finalFileName = baseFileName + "_" + timestamp + randomSuffix + ".json";

        String filePath = uploadDir + finalFileName;
        // 使用 ObjectMapper 将数据转换为 JSON 格式并保存到文件中
        ObjectMapper objectMapper = new ObjectMapper();
        try (FileWriter fileWriter = new FileWriter(filePath)) {
            String jsonData = objectMapper.writeValueAsString(data);
            fileWriter.write(jsonData);
            fileWriter.flush();
        } catch (IOException e) {
            throw new RuntimeException("文件保存失败", e);
        }

        return filePath;
    }
    private String saveDataToFileV1(List<List<String>> data, String baseFileName) {
        // 生成唯一文件名：毫秒时间戳 + 3位随机数字
        String timestamp = String.valueOf(System.currentTimeMillis());
        String randomSuffix = String.format("%03d", new Random().nextInt(2000));
        String finalFileName =   timestamp +"_" +randomSuffix + baseFileName+ ".json";
        String filePath = uploadDir + finalFileName;
        // 使用 ObjectMapper 将数据转换为 JSON 格式并保存到文件中
        ObjectMapper objectMapper = new ObjectMapper();
        try (FileWriter fileWriter = new FileWriter(filePath)) {
            String jsonData = objectMapper.writeValueAsString(data);
            fileWriter.write(jsonData);
            fileWriter.flush();
        } catch (IOException e) {
            throw new RuntimeException("文件保存失败", e);
        }

        return filePath;
    }
//    private String saveDataToFile(List<List<String>> data, String baseFileName) {
//        // 生成唯一文件名：毫秒时间戳 + 3位随机数字
//        String timestamp = String.valueOf(System.currentTimeMillis());
//        String randomSuffix = String.format("%03d", new Random().nextInt(1000));
//        String finalFileName = baseFileName + "_" + timestamp + randomSuffix + ".json";
//
//        String filePath = uploadDir + finalFileName;
//        // 使用 ObjectMapper 将数据转换为 JSON 格式并保存到文件中
//        ObjectMapper objectMapper = new ObjectMapper();
//        try (FileWriter fileWriter = new FileWriter(filePath)) {
//            String jsonData = objectMapper.writeValueAsString(data);
//            fileWriter.write(jsonData);
//            fileWriter.flush();
//        } catch (IOException e) {
//            throw new RuntimeException("文件保存失败", e);
//        }
//
//        return filePath;
//    }


//    private String saveDataToFile(List<List<String>> data, String fileName) {
//        // 生成文件名
//        String filePath = uploadDir + fileName + ".json";
//
//        // 使用 ObjectMapper 将数据转换为 JSON 格式并保存到文件中
//        ObjectMapper objectMapper = new ObjectMapper();
//        try (FileWriter fileWriter = new FileWriter(filePath)) {
//            String jsonData = objectMapper.writeValueAsString(data);
//            fileWriter.write(jsonData);
//            fileWriter.flush();
//        } catch (IOException e) {
//            throw new RuntimeException("文件保存失败", e);
//        }
//
//        return filePath;
//    }

    public Integer saveFilsJson(String filePath,  String rawFilePath,Integer tableName, String fileName) {

        Integer id = IdUtils.generateRandomNumber();
        // 创建 SysFileAudit 对象并设置属性
        SysFileAudit audit = new SysFileAudit();
        audit.setId(id); // 生成唯一 ID
        audit.setFilePath(filePath);
        audit.setRawFilePath(rawFilePath);//新加的 用户解析Json用
        audit.setTableName(tableName);
        audit.setStatus(0); // 假设 0 表示未处理状态
        audit.setUserId(SecurityUtils.getUserId());
        audit.setName(fileName);
        // 方法1：通过 java.sql.Timestamp 转换（推荐，精确到毫秒）
        LocalDateTime localDateTime = LocalDateTime.now();
        Timestamp timestamp = Timestamp.from(localDateTime.atZone(ZoneId.systemDefault()).toInstant());
        audit.setCreateTime(timestamp);
        // 将文件记录保存到数据库
        sysFileAuditMapper.insert(audit);

        return id;
    }


    private AjaxResult validateInput(SaveDataDTO saveDataDTO) {

        // 1. 首先验证数据是否为空
        if (saveDataDTO.getData() == null || saveDataDTO.getData().isEmpty()) {
            throw new IllegalArgumentException("未检测到数据，请重新上传");
        }

        //校验之前去掉表头列
        // saveDataDTO.getData().remove(0);

        String targetTable;
        switch (saveDataDTO.getTableName()) {
            case 1:
                targetTable = "sys_cement";
                // 这里可以执行与 sys_cement 相关的保存操作 1： 水泥
                return checkCement(saveDataDTO.getData());

            case 2:
                targetTable = "sys_sand";
                // 这里可以执行与 sys_sand 相关的保存操作  2： 砂
                return checkSand(saveDataDTO.getData());

            case 3:
                targetTable = "sys_stone";
                // 这里可以执行与 sys_stone 相关的保存操作 3： 石
                return checkStone(saveDataDTO.getData());

            case 4:
                targetTable = "sys_flyash";
                // 对 sys_flyash 进行数据校验           4： 粉煤灰
                return checkFlyash(saveDataDTO.getData());
            // 执行完 sys_flyash 保存逻辑后直接返回，不继续执行后续操作
            case 5:
                targetTable = "sys_water_reducer";
                // 这里可以执行与 sys_water_reducer 相关的保存操作 5： 减水剂
                // checkWaterReducer(saveDataDTO.getData());
                return checkWaterReducer(saveDataDTO.getData());
            case 6:
                targetTable = "sys_efficiency_agent";
                // 这里可以执行与 sys_efficiency_agent 相关的保存操作 6： 增效剂
                return checkEfficiencyAgent(saveDataDTO.getData());
            case 7:
                targetTable = "";
                // 这里可以执行与 sys_mechanical_performance 相关的保存操作 7：力学性能
                return checkMechanicalPerformance(saveDataDTO.getData());

            case 8:
                targetTable = "";
                // 这里可以执行与 sys_deformation_performance 相关的保存操作 8：变形性能
                return checkDeformationPerformance(saveDataDTO.getData());

            case 9:
                targetTable = "";
                // 这里可以执行与 sys_durability_performance 相关的保存操作 9：耐久性能
                return checkDurabilityPerformance(saveDataDTO.getData());
            case 10:

                //10水
                return checkWaterPerformance(saveDataDTO.getData());

            case 11:
                //11矿粉
                return checkMineralPowderformance(saveDataDTO.getData());

            case 12:
                //12其他参合料
                return checkOtherAdmixturesformance(saveDataDTO.getData());

            case 13:
                //13膨胀剂
                return checkSwellingagentAdmixturesformance(saveDataDTO.getData());

            case 14:
                //14坍落度
                return checkSysSlump(saveDataDTO.getData());


            default:
                throw new IllegalArgumentException("无效的表名编号");
        }

    }


    //校验水泥表     1： 水泥
    public boolean isNumber(String str) {
        if (str == null || str.trim().isEmpty()) {
            return false;
        }
        // 匹配整数或浮点数（包括负数）
        return str.matches("^[+-]?([0-9]*[.])?[0-9]+$");
    }

    private AjaxResult checkCement(List<List<String>> data) {
        if (data == null || data.size() <= 1) {
            return AjaxResult.error("请上传包含至少一条数据的文件");
        }

        // 校验之前去掉表头列
        data.remove(0); // 去掉表头

        // 查询所有未删除的地区
        LambdaQueryWrapper<Region> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Region::getDeleteTime, 0);
        List<Region> regionList = regionService.list(wrapper);

        // 构建 fullName -> Region 的 Map
        Map<String, Region> fullNameMap = new HashMap<>();
        for (Region r : regionList) {
            fullNameMap.put(r.getFullName(), r);
        }

        for (int i = 0; i < data.size(); i++) {

            System.out.println("我是data数据" + data);


            List<String> row = data.get(i);
            if (row == null || row.size() != 7) {
                return AjaxResult.error("第 " + (i + 1) + " 行：必须包含 7 个字段");
            }

            String model = row.get(0);
            String cao = row.get(1);
            String sio2 = row.get(2);
            String al2o3 = row.get(3);
            String compressive = row.get(4);
            String strengthGrade = row.get(5);
            String regionName = row.get(6);

            if (isBlank(model)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：型号不能为空");
            }
            if (!isNumber(cao)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：CaO 含量应为数字");
            }
            if (!isNumber(sio2)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：SiO2 含量应为数字");
            }
            if (!isNumber(al2o3)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：Al2O3 含量应为数字");
            }

            if (!isNumber(compressive)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：抗压强度应为数字");
            }
            if (!isNumber(strengthGrade)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：强度等级应为数字");
            }


           // String regionPattern = "^([\\u4e00-\\u9fa5]{2,}(省|市))(-[\\u4e00-\\u9fa5]+市)?(-[\\u4e00-\\u9fa5]+(市|区|县))?$";
            String regionPattern = "^([\\u4e00-\\u9fa5]{2,}(省|市))?(?:-[\\u4e00-\\u9fa5]{2,}(市|州|盟|区|县))?(?:-[\\u4e00-\\u9fa5]{2,}(市|区|县|旗))?$";
            if (!regionName.matches(regionPattern)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区格式不正确，应为“浙江省”或“浙江省-杭州市”或“浙江省-杭州市-余杭区”或“北京”或“北京市”");
            }


//            Region matched = matchOrInsertRegion(regionName, fullNameMap);
//            if (matched == null) {
//                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + regionName);
//            }
//
//            row.set(1, String.valueOf(matched.getId())); // 替换地区为 ID，便于后续入库

            Region matched = matchOrInsertRegion(regionName, fullNameMap);
            if (matched == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + regionName);
            }

            row.set(6, String.valueOf(matched.getId())); //  设置正确的索引，替换地区为 ID

        }

        return AjaxResult.success("水泥数据校验通过，地区已处理");
    }


    // 匹配或者插入一个新的地区
    private Region matchOrInsertRegion(String input, Map<String, Region> regionMap) {
        // 使用 "-" 分割输入的地区名称，假设格式为 "省-市-区"
        String[] parts = input.split("-");

        Region province = null;
        Region city = null;
        Region district = null;

        // 获取省份的名称
        String provinceName = parts[0];
        // 根据省的名称从缓存的 regionMap 中获取省份对象
        province = regionMap.get(provinceName);
        // 如果省份不存在，则插入新的省份
        if (province == null) {
            province = insertRegion(provinceName, null, 1); // 1 代表省份的级别
            regionMap.put(provinceName, province); // 将新创建的省份放入缓存
        }

        // 如果输入有市，处理市的部分
        if (parts.length >= 2) {
            // 组合完整的市名称（包括省名）
            String cityFull = provinceName + "-" + parts[1];
            city = regionMap.get(cityFull); // 获取市级对象
            // 如果市级不存在，则插入新的市
            if (city == null) {
                city = insertRegion(parts[1], province.getId(), 2); // 2 代表市的级别
                regionMap.put(cityFull, city); // 将新创建的市放入缓存
            }
        }

        // 如果输入有区，处理区的部分
        if (parts.length == 3) {
            // 组合完整的区名称（包括省市名）
            String districtFull = provinceName + "-" + parts[1] + "-" + parts[2];
            district = regionMap.get(districtFull); // 获取区级对象
            // 如果区级不存在，则插入新的区
            if (district == null) {
                district = insertRegion(parts[2], city.getId(), 3); // 3 代表区的级别
                regionMap.put(districtFull, district); // 将新创建的区放入缓存
            }
        }

        // 根据层级返回最具体的区域，如果有区返回区，否则返回市，若都没有则返回省
        return district != null ? district : (city != null ? city : province);
    }

    // 插入一个新的地区
    private Region insertRegion(String name, Integer parentId, int level) {
        Region region = new Region();
        region.setName(name); // 设置地区名称
        region.setParentId(parentId); // 设置父地区的ID
        region.setLevel(level); // 设置地区的级别，1-省，2-市，3-区

        // 如果没有父地区，说明这是一个顶级区域
        if (parentId == null) {
            region.setFullName(name); // 顶级区域的全名就是它自己
        } else {
            // 否则，构建完整的地区全名（父地区全名 + 当前地区名称）
            Region parent = regionService.getById(parentId); // 从数据库获取父地区对象
            region.setFullName(parent.getFullName() + "-" + name);
        }

        // 设置区域的唯一标识码
        region.setCode("TMP" + System.currentTimeMillis());
        // 设置创建时间
        region.setCreateTime(LocalDateTime.now()); // 使用 Java 8 的日期时间 API
        // 设置版本号
        region.setVersion(1);
        // 设置删除时间标志，0 表示没有删除
        region.setDeleteTime(0);

        // 保存到数据库
        regionService.save(region);
        return region;
    }


//    private Region matchOrInsertRegion(String input, Map<String, Region> regionMap) {
//        String[] parts = input.split("-");
//
//        Region province = null;
//        Region city = null;
//        Region district = null;
//
//        String provinceName = parts[0];
//        province = regionMap.get(provinceName);
//        if (province == null) {
//            province = insertRegion(provinceName, null, 1);
//            regionMap.put(provinceName, province);
//        }
//
//        if (parts.length >= 2) {
//            String cityFull = provinceName + "-" + parts[1];
//            city = regionMap.get(cityFull);
//            if (city == null) {
//                city = insertRegion(parts[1], province.getId(), 2);
//                regionMap.put(cityFull, city);
//            }
//        }
//
//        if (parts.length == 3) {
//            String districtFull = provinceName + "-" + parts[1] + "-" + parts[2];
//            district = regionMap.get(districtFull);
//            if (district == null) {
//                district = insertRegion(parts[2], city.getId(), 3);
//                regionMap.put(districtFull, district);
//            }
//        }
//
//        return district != null ? district : (city != null ? city : province);
//    }
//
//    private Region insertRegion(String name, Integer parentId, int level) {
//        Region region = new Region();
//        region.setName(name);
//        region.setParentId(parentId);
//        region.setLevel(level); // 假如 level 是 Integer 类型
//
//
//        if (parentId == null) {
//            region.setFullName(name);
//        } else {
//            Region parent = regionService.getById(parentId);
//            region.setFullName(parent.getFullName() + "-" + name);
//        }
//
//        region.setCode("TMP" + System.currentTimeMillis());
//        region.setCreateTime(LocalDateTime.now()); // Java 8 用 java.util.Date 兼容数据库 datetime
//        region.setVersion(1);
//        region.setDeleteTime(0);
//
//        regionService.save(region);
//        return region;
//    }
//


//    private AjaxResult checkCement(List<List<String>> data) {
//        // 获取已有的地区（未软删除）
//
//
//        LambdaQueryWrapper<Region> wrapper = new LambdaQueryWrapper<>();
//        wrapper.eq(Region::getDeleteTime,0);
//        List<Region> RegionList = regionService.list(wrapper);
//
//        Map<Integer, Region> regionMap = RegionList.stream().collect(Collectors.toMap(Region::getId, Function.identity()));
//
//        // 你可以在这里继续用 regionMap 进行比对逻辑等操作
//        System.out.println("Region Map Size: " + regionMap.size());
//
//        // 校验 data 中每个元素的格式
//
//        // 遍历每一行数据（跳过标题）
//        for (int i = 1; i < data.size(); i++) {
//            List<String> row = data.get(i);
//            if (row == null || row.size() != 7) {
//                return AjaxResult.error("第 " + (i + 1) + " 行：数据格式错误，必须包含 7 个元素");
//            }
//
//            String model = row.get(0);
//            String regionName = row.get(1);
//            String strengthGrade = row.get(2);
//            String cao = row.get(3);
//            String sio2 = row.get(4);
//            String al2o3 = row.get(5);
//            String compressive28d = row.get(6);
//
//            // 1. 非空校验
//            if (model.trim().isEmpty() || regionName.trim().isEmpty()) {
//                return AjaxResult.error("第 " + (i + 1) + " 行：型号或地区不能为空");
//            }
//
//            // 2. 数值校验
//            if (!isNumber(strengthGrade)) return AjaxResult.error("第 " + (i + 1) + " 行：强度等级应为数字");
//            if (!isNumber(cao)) return AjaxResult.error("第 " + (i + 1) + " 行：CaO 含量应为数字");
//            if (!isNumber(sio2)) return AjaxResult.error("第 " + (i + 1) + " 行：SiO2 含量应为数字");
//            if (!isNumber(al2o3)) return AjaxResult.error("第 " + (i + 1) + " 行：Al2O3 含量应为数字");
//            if (!isNumber(compressive28d)) return AjaxResult.error("第 " + (i + 1) + " 行：28天抗压强度应为数字");
//
//            // 3. 地区校验：支持省、省市、省市区，自动插入
//            Region matchedRegion = matchOrInsertRegion(regionName, fullNameMap);
//            if (matchedRegion == null) {
//                return AjaxResult.error("第 " + (i + 1) + " 行：地区处理失败 - " + regionName);
//            }
//
//            // 替换 row 的地区字段为对应 ID（可选）
//            row.set(1, String.valueOf(matchedRegion.getId()));
//
//
//        }
//
//
//
//
//
//
////        for (List<String> item : data) {
////
////            System.out.println("我是data数据"+data);
////            // 遍历每一行数据（跳过标题）
////
////                List<String> row = data.get(i);
////                if (row == null || row.size() != 7) {
////                    return AjaxResult.error("第 " + (i + 1) + " 行：数据格式错误，必须包含 7 个元素");
////                }
////
////            // 对第一个元素进行检查是否为有效的水泥规格格式
////            String cementModel = item.get(0);
////            String cementRegionName = item.get(1);
////            String cementStrengthGrade = item.get(2);
////            String cementCaocontent = item.get(3);
////            String cementSio2Content = item.get(4);
////            String cementAl2o3Content = item.get(5);
////            String cementCompressiveStrength28d = item.get(6);
////
////
////            if (cementModel == null || cementModel.trim().isEmpty()) {
////                return AjaxResult.error("第一个元素不应为空或仅包含空白字符");
////            }
////
////            if (cementRegionName == null || cementRegionName.trim().isEmpty()) {
////                return AjaxResult.error("第二个元素不应为空或仅包含空白字符");
////            }
////
////
////
////
//////
//////            if (!level2.matches("^-?\\d*(\\.\\d+)?$")) {
//////                return AjaxResult.error("第二个元素应为有效的数字（可以是阿拉伯数字或带小数点）！");
//////            }
//////
//////
//////
//////
//////
//////            // 对第三个元素进行检查是否为有效的数字（阿拉伯数字或带小数点）
//////            String level3 = item.get(2);
//////            if (level3 == null || level3.trim().isEmpty()) {
//////                return AjaxResult.error("第二个元素不应为空或仅包含空白字符");
//////            }
//////
//////            if (!level3.matches("^-?\\d*(\\.\\d+)?$")) {
//////                return AjaxResult.error("第三个元素应为有效的数字（可以是阿拉伯数字或带小数点）！");
//////            }
//////
//////
//////
//////
//////            // 对第四个元素进行检查是否为有效的数字（阿拉伯数字或带小数点）
//////            String level4 = item.get(3);
//////            if (level4 == null || level4.trim().isEmpty()) {
//////                return AjaxResult.error("第三个元素不应为空或仅包含空白字符");
//////            }
//////
//////            if (!level4.matches("^-?\\d*(\\.\\d+)?$")) {
//////                return AjaxResult.error("第四个元素应为有效的数字（可以是阿拉伯数字或带小数点）！");
//////            }
//////
//////
//////
//////
//////            //校验第5个为中文
//////            //阿拉伯数字校验 好用
//////            //对类型进行检查是否为中 文文字 好用
//////            String chineseTextItem = item.get(4);
//////            if (!chineseTextItem.matches("[\\u4e00-\\u9fa5]+")) {
//////                return AjaxResult.error("第五个元素应为有效的中文文字");
//////            }
////
////
////
////        }
//
//
//        return AjaxResult.success();
//    }


    // 校验 sys_stand 表的 data 格式       2： 砂
    private AjaxResult checkSand(List<List<String>> data) {
        if (data == null || data.size() <= 1) {
            return AjaxResult.error("请上传包含至少一条数据的文件");
        }

        // 校验之前去掉表头列
        data.remove(0); // 去掉表头

        // 查询所有未删除的地区
        LambdaQueryWrapper<Region> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Region::getDeleteTime, 0);
        List<Region> regionList = regionService.list(wrapper);

        // 构建 fullName -> Region 的 Map
        Map<String, Region> fullNameMap = new HashMap<>();
        for (Region r : regionList) {
            fullNameMap.put(r.getFullName(), r);
        }

        for (int i = 0; i < data.size(); i++) {

            System.out.println("我是data数据" + data);


            List<String> row = data.get(i);
            if (row == null || row.size() != 7) {
                return AjaxResult.error("第 " + (i + 1) + " 行：必须包含 7 个字段");
            }

            String model = row.get(0);//型号

            String fineness = row.get(1);//细度
            String bulkDensity = row.get(2);//堆积密度 (kg/m3)
            String compactDensity = row.get(3);//紧密密度 (kg/m3)
            String apparentDensity = row.get(4);//表观密度 (kg/m3)

            String particleSizeDistribution = row.get(5);//粒径分布(mm)
            String regionName = row.get(6);


            if (isBlank(model)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：型号不能为空");
            }
            if (isBlank(fineness)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：细度不能为空");
            }
            if (isBlank(particleSizeDistribution)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：粒径分布不能为空");
            }


            if (!isNumber(bulkDensity)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：堆积密度应为数字");
            }
            if (!isNumber(compactDensity)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：紧密密度应为数字");
            }
            if (!isNumber(apparentDensity)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：表观密度应为数字");
            }


         //   String regionPattern = "^([\\u4e00-\\u9fa5]{2,}(省|市))(-[\\u4e00-\\u9fa5]+市)?(-[\\u4e00-\\u9fa5]+(区|县))?$";
            String regionPattern = "^([\\u4e00-\\u9fa5]{2,}(省|市))?(?:-[\\u4e00-\\u9fa5]{2,}(市|州|盟|区|县))?(?:-[\\u4e00-\\u9fa5]{2,}(市|区|县|旗))?$";
            if (!regionName.matches(regionPattern)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区格式不正确，应为“浙江省”或“浙江省-杭州市”或“浙江省-杭州市-余杭区”或“北京”或“北京市”");
            }


//            Region matched = matchOrInsertRegion(regionName, fullNameMap);
//            if (matched == null) {
//                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + regionName);
//            }
//
//            row.set(1, String.valueOf(matched.getId())); // 替换地区为 ID，便于后续入库

            Region matched = matchOrInsertRegion(regionName, fullNameMap);
            if (matched == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + regionName);
            }

            row.set(6, String.valueOf(matched.getId()));

        }
        return AjaxResult.success("水泥数据校验通过，地区已处理");
    }


    // 校验 sys_stone 表的 data 格式       3： 石
    private AjaxResult checkStone(List<List<String>> data) {

        if (data == null || data.size() <= 1) {
            return AjaxResult.error("请上传包含至少一条数据的文件");
        }

        // 校验之前去掉表头列
        data.remove(0); // 去掉表头

        // 查询所有未删除的地区
        LambdaQueryWrapper<Region> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Region::getDeleteTime, 0);
        List<Region> regionList = regionService.list(wrapper);

        // 构建 fullName -> Region 的 Map
        Map<String, Region> fullNameMap = new HashMap<>();
        for (Region r : regionList) {
            fullNameMap.put(r.getFullName(), r);
        }

        for (int i = 0; i < data.size(); i++) {

            System.out.println("我是data数据" + data);


            List<String> row = data.get(i);
            if (row == null || row.size() != 6) {
                return AjaxResult.error("第 " + (i + 1) + " 行：必须包含 6 个字段");
            }

            String model = row.get(0); //型号
            String stoneSpecification = row.get(1);//石子规格
            String stackingDensity = row.get(2);//堆积密度
            String compactDensity = row.get(3);//紧密密度
            String bulkdensity = row.get(4);//表观密度
            String regionName = row.get(5);//来源地区


            if (isBlank(model)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：型号不能为空");
            }
            if (isBlank(stoneSpecification)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：石子规格 不能为空");
            }
            if (!isNumber(stackingDensity)) {
                return AjaxResult.error("第 " + (i + 1) + " 行堆积密度应为数字");
            }
            if (!isNumber(compactDensity)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：紧密密度应为数字");
            }

            if (!isNumber(bulkdensity)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：表观密度应为数字");
            }

           // String regionPattern = "^([\\u4e00-\\u9fa5]{2,}(省|市))(-[\\u4e00-\\u9fa5]+市)?(-[\\u4e00-\\u9fa5]+(区|县))?$";
            String regionPattern = "^([\\u4e00-\\u9fa5]{2,}(省|市))?(?:-[\\u4e00-\\u9fa5]{2,}(市|州|盟|区|县))?(?:-[\\u4e00-\\u9fa5]{2,}(市|区|县|旗))?$";
            if (!regionName.matches(regionPattern)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区格式不正确，应为“浙江省”或“浙江省-杭州市”或“浙江省-杭州市-余杭区”或“北京”或“北京市”");
            }


//            Region matched = matchOrInsertRegion(regionName, fullNameMap);
//            if (matched == null) {
//                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + regionName);
//            }
//
//            row.set(1, String.valueOf(matched.getId())); // 替换地区为 ID，便于后续入库

            Region matched = matchOrInsertRegion(regionName, fullNameMap);
            if (matched == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + regionName);
            }
            row.set(5, String.valueOf(matched.getId()));
        }

        return AjaxResult.success("水泥数据校验通过，地区已处理");
    }


    // 校验 sys_flyash 表的 data 格式     4： 粉煤灰
    private AjaxResult checkFlyash(List<List<String>> data) {


        if (data == null || data.size() <= 1) {
            return AjaxResult.error("请上传包含至少一条数据的文件");
        }

        // 校验之前去掉表头列
        data.remove(0); // 去掉表头

        // 查询所有未删除的地区
        LambdaQueryWrapper<Region> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Region::getDeleteTime, 0);
        List<Region> regionList = regionService.list(wrapper);

        // 构建 fullName -> Region 的 Map
        Map<String, Region> fullNameMap = new HashMap<>();
        for (Region r : regionList) {
            fullNameMap.put(r.getFullName(), r);
        }

        for (int i = 0; i < data.size(); i++) {

            System.out.println("我是data数据" + data);


            List<String> row = data.get(i);
            if (row == null || row.size() != 6) {
                return AjaxResult.error("第 " + (i + 1) + " 行：必须包含 6 个字段");
            }

            String model = row.get(0); //型号
            String factoryGrade = row.get(1); //出厂等级
            String fineness = row.get(2);//细度(%)
            String moistureContent = row.get(3);//含水量(%
            String activityIndex28d = row.get(4);//28天活性指数(%)
            String regionName = row.get(5);//来源地区


            if (isBlank(model)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：型号不能为空");
            }
            if (isBlank(factoryGrade)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：出厂等级不能为空");
            }
            if (!isNumber(fineness)) {
                return AjaxResult.error("第 " + (i + 1) + " 行堆积密度应为数字");
            }
            if (!isNumber(moistureContent)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：紧密密度应为数字");
            }

            if (!isNumber(activityIndex28d)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：表观密度应为数字");
            }


            //String regionPattern = "^([\\u4e00-\\u9fa5]{2,}(省|市))(-[\\u4e00-\\u9fa5]+市)?(-[\\u4e00-\\u9fa5]+(区|县))?$";
            String regionPattern = "^([\\u4e00-\\u9fa5]{2,}(省|市))?(?:-[\\u4e00-\\u9fa5]{2,}(市|州|盟|区|县))?(?:-[\\u4e00-\\u9fa5]{2,}(市|区|县|旗))?$";
            if (!regionName.matches(regionPattern)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区格式不正确，应为“浙江省”或“浙江省-杭州市”或“浙江省-杭州市-余杭区”或“北京”或“北京市”");
            }

//            Region matched = matchOrInsertRegion(regionName, fullNameMap);
//            if (matched == null) {
//                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + regionName);
//            }
//
//            row.set(1, String.valueOf(matched.getId())); // 替换地区为 ID，便于后续入库

            Region matched = matchOrInsertRegion(regionName, fullNameMap);
            if (matched == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + regionName);
            }
            row.set(5, String.valueOf(matched.getId()));
        }

        return AjaxResult.success("水泥数据校验通过，地区已处理");


    }


    //校验减水剂表                        5： 减水剂
    private AjaxResult checkWaterReducer(List<List<String>> data) {
        if (data == null || data.size() <= 1) {
            return AjaxResult.error("请上传包含至少一条数据的文件");
        }

        // 校验之前去掉表头列
        data.remove(0); // 去掉表头


        for (int i = 0; i < data.size(); i++) {

            System.out.println("我是data数据" + data);


            List<String> row = data.get(i);
            if (row == null || row.size() != 7) {
                return AjaxResult.error("第 " + (i + 1) + " 行：必须包含 7 个字段");
            }

            String model = row.get(0);//型号
            String solidContent = row.get(1);//含固量(%)
            String cementPasteFlow = row.get(2);//水泥净浆流动度(mm)
            String reducingRate = row.get(3);//减水率
            String regionName = row.get(4);//来源

            String photo1 = row.get(5);//来源
            String photo2 = row.get(6);//来源

            if (isBlank(model)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：型号不能为空");
            }

            if (!isNumber(solidContent)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：含固量(%)应为数字");
            }
            if (!isNumber(cementPasteFlow)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：水泥净浆流动度(mm)应为数字");
            }
            if (!isNumber(reducingRate)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：减水率应为数字");
            }

            if (isBlank(photo1)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：照片地址不能为空");
            }


            if (isBlank(photo2)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：照片地址不能为空");
            }
            if (isBlank(regionName)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：商家来源不能为空");
            }
//            String regionPattern = "^([\\u4e00-\\u9fa5]+省)(-[\\u4e00-\\u9fa5]+市)?(-[\\u4e00-\\u9fa5]+(区|县))?$";
//            if (!regionName.matches(regionPattern)) {
//                return AjaxResult.error("第 " + (i + 1) + " 行：地区格式不正确，应为“浙江省”或“浙江省-杭州市”或“浙江省-杭州市-余杭区/余杭县”");
//            }



        }
        return AjaxResult.success("减水剂校验通过");
    }


    //校验增效剂表                         6： 增效剂
    private AjaxResult checkEfficiencyAgent(List<List<String>> data) {
        if (data == null || data.size() <= 1) {
            return AjaxResult.error("请上传包含至少一条数据的文件");
        }

        // 校验之前去掉表头列
        data.remove(0); // 去掉表头


        for (int i = 0; i < data.size(); i++) {

            System.out.println("我是data数据" + data);


            List<String> row = data.get(i);
            if (row == null || row.size() != 2) {
                return AjaxResult.error("第 " + (i + 1) + " 行：必须包含 2 个字段");
            }

            String model = row.get(0);//型号
            String regionName = row.get(1);//来源


            if (isBlank(model)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：型号不能为空");
            }

            if (isBlank(regionName)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：商家来源不能为空");
            }



        }
        return AjaxResult.success("增效剂校验通过");
    }


    //校验力学性能表     7：力学性能数据
    private AjaxResult checkMechanicalPerformance(List<List<String>> data) {
        if (data == null || data.size() <= 1) {
            return AjaxResult.error("请上传包含至少一条数据的文件");
        }
        // 校验之前去掉表头列
        data.remove(0); // 去掉表头

        // 查询所有未删除的地区
        LambdaQueryWrapper<Region> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Region::getDeleteTime, 0);
        List<Region> regionList = regionService.list(wrapper);


        // 构建 fullName -> Region 的 Map
        Map<String, Region> fullNameMap = new HashMap<>();
        for (Region r : regionList) {
            fullNameMap.put(r.getFullName(), r);
        }


        for (int i = 0; i < data.size(); i++) {

            System.out.println("我是data数据" + data);


            List<String> row = data.get(i);

//            if (row == null || row.size() != 22) {
//                return AjaxResult.error("第 " + (i + 1) + " 行：必须包含 22个字段");
//            }

            String region = row.get(0); //地区
            String productionDate = row.get(1);//生产日期
            String strengthGrade = row.get(2);//强度等级
            String compressive3d = row.get(3);//3天抗压强度(MPa)
            String compressive7d = row.get(4);//7天抗压强度(MPa)
            String compressive28d = row.get(5);//28天抗压强度(MPa)
            String water = row.get(6);//水掺量(kg/m³)
            String cement = row.get(7);//水泥掺量(kg/m³)

            /*水泥*/
            String cementModel = row.get(8);//水泥型号
            String cementCao = row.get(9);//水泥CaO含量
            String cementSio2 = row.get(10);//水泥SiO2含量
            String cementAl2o3 = row.get(11);//水泥Al2O3含量

//            String cementStrengthGrade = row.get(12);//28天
//            String cementCompressive = row.get(13);//强度等级

            String cementStrengthGrade = row.get(12);// 强度等级
            String cementCompressive = row.get(13);//28天

            String cementRegionName = row.get(14);//水泥地区


            String stone510 = row.get(15); //掺量  石头5-10
            String model = row.get(16); //型号  石头5-10
            String stoneSpecification = row.get(17);//石子规格   石头5-10
            String stackingDensity = row.get(18);//堆积密度    石头5-10
            String compactDensity = row.get(19);//紧密密度  石头5-10
            String bulkdensity = row.get(20);//表观密度      石头5-10
            String regionNamestone510 = row.get(21);//来源地区      石头5-10


            String stone525 = row.get(22); //掺量  石头5-25
            String model525 = row.get(23); //型号  石头5-25
            String stoneSpecification525 = row.get(24);//石子规格   石头5-25
            String stackingDensity525 = row.get(25);//堆积密度    石头5-25
            String compactDensity525 = row.get(26);//紧密密度  石头5-25
            String bulkdensity525 = row.get(27);//表观密度      石头5-25
            String regionNamestone525 = row.get(28);//来源地区      石头5-25


            String stone2040 = row.get(29); //掺量  石头20-40mm
            String model2040 = row.get(30); //型号  石头20-40mm
            String stoneSpecification2040 = row.get(31);//石子规格   石头20-40mm
            String stackingDensity2040 = row.get(32);//堆积密度    石头20-40mm
            String compactDensity2040 = row.get(33);//紧密密度  石头20-40mm
            String bulkdensity2040 = row.get(34);//表观密度      石头20-40mm
            String regionNamestone2040 = row.get(35);//来源地区      石头20-40mm


            String stone1020 = row.get(36); //掺量  石头20-40mm
            String model1020 = row.get(37); //型号  石头20-40mm
            String stoneSpecification1020 = row.get(38);//石子规格   石头20-40mm
            String stackingDensity1020 = row.get(39);//堆积密度    石头20-40mm
            String compactDensity1020 = row.get(40);//紧密密度  石头20-40mm
            String bulkdensity1020 = row.get(41);//表观密度      石头20-40mm
            String regionNamestone1020 = row.get(42);//来源地区      石头20-40mm


            String stone1030 = row.get(43); //掺量  石头10-30mm
            String model1030 = row.get(44); //型号  石头10-30mm
            String stoneSpecification1030 = row.get(45);//石子规格   石头10-30mm
            String stackingDensity1030 = row.get(46);//堆积密度    石头10-30mm
            String compactDensity1030 = row.get(47);//紧密密度  石头10-30mm
            String bulkdensity1030 = row.get(48);//表观密度      石头10-30mm
            String regionNamestone1030 = row.get(49);//来源地区      石头10-30mm


            String stone010 = row.get(50); //掺量  石头0-10mm
            String model010 = row.get(51); //型号  石头10-30mm
            String stoneSpecification010 = row.get(52);//石子规格   石头10-30mm
            String stackingDensity010 = row.get(53);//堆积密度    石头10-30mm
            String compactDensity010 = row.get(54);//紧密密度  石头10-30mm
            String bulkdensity010 = row.get(55);//表观密度      石头10-30mm
            String regionNamestone010 = row.get(56);//来源地区      石头10-30mm


            String stone20315 = row.get(57); //掺量  石头0-10mm
            String model20315 = row.get(58); //型号  石头10-30mm
            String stoneSpecification20315 = row.get(59);//石子规格   石头10-30mm
            String stackingDensity20315 = row.get(60);//堆积密度    石头10-30mm
            String compactDensity20315 = row.get(61);//紧密密度  石头10-30mm
            String bulkdensity20315 = row.get(62);//表观密度      石头10-30mm
            String regionNamestone20315 = row.get(63);//来源地区      石头10-30mm





            /*河砂粗3.1-3.7mm*/
            String sand3137 = row.get(64);//砂掺量

            String model3137 = row.get(65);//型号
            String fineness3137 = row.get(66);//细度
            String bulkDensity3137 = row.get(67);//堆积密度 (kg/m3)
            String compactDensity3137 = row.get(68);//紧密密度 (kg/m3)
            String apparentDensity3137 = row.get(69);//表观密度 (kg/m3)

            String particleSizeDistribution3137 = row.get(70);//粒径分布(mm)
            String regionSandName3137 = row.get(71);



            /*河砂粗砂23-30*/
            String sand2330 = row.get(72);//砂掺量

            String model2330 = row.get(73);//型号
            String fineness2330 = row.get(74);//细度
            String bulkDensity2330 = row.get(75);//堆积密度 (kg/m3)
            String compactDensity2330 = row.get(76);//紧密密度 (kg/m3)
            String apparentDensity2330 = row.get(77);//表观密度 (kg/m3)
            String particleSizeDistribution2330 = row.get(78);//粒径分布(mm)
            String regionSandName2330 = row.get(79);



            /*河砂细16-22mm*/
            String sand1622 = row.get(80);//砂掺量

            String model1622 = row.get(81);//型号
            String fineness1622 = row.get(82);//细度
            String bulkDensity1622 = row.get(83);//堆积密度 (kg/m3)
            String compactDensity1622 = row.get(84);//紧密密度 (kg/m3)
            String apparentDensity1622 = row.get(85);//表观密度 (kg/m3)
            String particleSizeDistribution1622 = row.get(86);//粒径分布(mm)
            String regionSandName1622 = row.get(87);



            /*机制砂中23-30Bmm*/
            String sand2330B = row.get(88);//砂掺量

            String model2330B = row.get(89);//型号
            String fineness2330B = row.get(90);//细度
            String bulkDensity2330B = row.get(91);//堆积密度 (kg/m3)
            String compactDensity2330B = row.get(92);//紧密密度 (kg/m3)
            String apparentDensity2330B = row.get(93);//表观密度 (kg/m3)
            String particleSizeDistribution2330B = row.get(94);//粒径分布(mm)
            String regionSandName2330B = row.get(95);




            /*机制砂粗31-37Bmm*/
            String sand3137B = row.get(96);//砂掺量
            String model3137B = row.get(97);//型号
            String fineness3137B = row.get(98);//细度
            String bulkDensity3137B = row.get(99);//堆积密度 (kg/m3)
            String compactDensity3137B = row.get(100);//紧密密度 (kg/m3)
            String apparentDensity3137B = row.get(101);//表观密度 (kg/m3)
            String particleSizeDistribution3137B = row.get(102);//粒径分布(mm)
            String regionSandName3137B = row.get(103);


            /*机制砂细16-22Bmm*/
            String sand1622B = row.get(104);//砂掺量
            String model1622B = row.get(105);//型号
            String fineness1622B = row.get(106);//细度
            String bulkDensity1622B = row.get(107);//堆积密度 (kg/m3)
            String compactDensity1622B = row.get(108);//紧密密度 (kg/m3)
            String apparentDensity1622B = row.get(109);//表观密度 (kg/m3)
            String particleSizeDistribution1622B = row.get(110);//粒径分布(mm)
            String regionSandName1622B = row.get(111);


            /*机制砂0-4.75mm*/
            String sand0475 = row.get(112);//砂掺量
            String model0475 = row.get(113);//型号
            String fineness0475 = row.get(114);//细度
            String bulkDensity0475 = row.get(115);//堆积密度 (kg/m3)
            String compactDensity0475 = row.get(116);//紧密密度 (kg/m3)
            String apparentDensity0475 = row.get(117);//表观密度 (kg/m3)
            String particleSizeDistribution0475 = row.get(118);//粒径分布(mm)
            String regionSandName0475 = row.get(119);




            /*机制砂0-9mm*/
            String sand09 = row.get(120);//砂掺量
            String model09 = row.get(121);//型号
            String fineness09 = row.get(122);//细度
            String bulkDensity09 = row.get(123);//堆积密度 (kg/m3)
            String compactDensity09 = row.get(124);//紧密密度 (kg/m3)
            String apparentDensity09 = row.get(125);//表观密度 (kg/m3)
            String particleSizeDistribution09 = row.get(126);//粒径分布(mm)
            String regionSandName09 = row.get(127);


            /*石粉*/
            String otherAdmixtures = row.get(128); //掺量
            String modelotherAdmixtures = row.get(129); //型号
            String finenessotherAdmixtures = row.get(130);//细度(%)
            String moistureContentotherAdmixtures = row.get(131);//含水量(%)
            String activityIndex28dOtherAdmixtures = row.get(132);//28天活性指数(%)
            String regionNameOtherAdmixtures = row.get(133);//来源地区



            /*矿粉*/


            String mineralPowder = row.get(134); //矿粉掺量

            String mineralPowdermodel = row.get(135); //型号
            String mineralPowderSlagGrade = row.get(136);//矿粉等级
            String mineralPowderFineness = row.get(137);//细度
            String mineralPowdermoistureContent = row.get(138);//含水量
            String mineralPowderactivityIndex28d = row.get(139);//28天活性指数
            String mineralPowderregionName = row.get(140);//来源地区


            String sysFlyash = row.get(141); //粉煤灰掺量

            String flyashModel = row.get(142); //粉煤灰型号
            String flyashFactoryGrade = row.get(143); //粉煤灰出厂等级
            String flyashFineness = row.get(144);//粉煤灰细度(%)
            String flyashMoistureContent = row.get(145);//粉煤灰含水量(%
            String flyashActivityIndex28d = row.get(146);//粉煤灰28天活性指数(%)
            String flyashRegionName = row.get(147);//粉煤灰来源地区


            String waterReducer = row.get(148);//减水剂掺量
            String waterReducerModel = row.get(149);//减水剂型号
            String waterReducersolidContent = row.get(150);//减水剂含固量(%)
            String waterReducercementPasteFlow = row.get(151);//减水剂水泥净浆流动度(mm)
            String waterReducerreducingRate = row.get(152);//减水剂减水率
            String waterReducerRegionName = row.get(153);//减水剂来源


            String efficiencyAgent = row.get(154);//增效剂掺量
            String efficiencyAgentModel = row.get(155);//增效剂型号
            String efficiencyAgentName = row.get(156);//增效剂来源


            String swellingagentAgent = row.get(157);//膨胀剂掺量
            String swellingagentModel = row.get(158);//膨胀剂型号
            String swellingagentName = row.get(159);//膨胀剂来源



            if (isBlank(region)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：型号不能为空");
            }



           // String regionPattern = "^([\\u4e00-\\u9fa5]{2,}(省|市))(-[\\u4e00-\\u9fa5]+市)?(-[\\u4e00-\\u9fa5]+(区|县))?$";
            String regionPattern = "^([\\u4e00-\\u9fa5]{2,}(省|市))?(?:-[\\u4e00-\\u9fa5]{2,}(市|州|盟|区|县))?(?:-[\\u4e00-\\u9fa5]{2,}(市|区|县|旗))?$";
            if (!region.matches(regionPattern)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区格式不正确，应为“浙江省”或“浙江省-杭州市”或“浙江省-杭州市-余杭区”或“北京”或“北京市”");
            }

            if (isBlank(productionDate)) {//1
                return AjaxResult.error("第 " + (i + 1) + " 行：生产日期为空");
            }



            if (isBlank(strengthGrade)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：强度等级为空");
            }
             // 校验格式：必须以大写字母 C 开头，后面跟数字
            if (!strengthGrade.matches("C\\d+")) {//2
                return AjaxResult.error("第 " + (i + 1) + " 行：强度等级格式错误，应为以大写字母C开头，后跟数字，如C30");
            }



            if (isBlank(compressive3d)) { //3
                return AjaxResult.error("第 " + (i + 1) + " 行：3天抗压强度(MPa)");
            }
            if (isBlank(compressive7d)) {//4
                return AjaxResult.error("第 " + (i + 1) + " 行：7天抗压强度");
            }
            if (isBlank(compressive28d)) {//5
                return AjaxResult.error("第 " + (i + 1) + " 行：28天抗压强度(MPa)");
            }



            if (!isNumber(water)) {//6
                return AjaxResult.error("第 " + (i + 1) + " 行：水掺量(kg/m³)应为数字");
            }

            if (!isNumber(cement)) {//7
                return AjaxResult.error("第 " + (i + 1) + " 行：水泥掺量(kg/m³)应为数字");
            }


            if (isBlank(cementModel)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：水泥型号不能为空");
            }
            if (isBlank(cementCao)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：水泥CaO含量不能为空");
            }
            if (isBlank(cementSio2)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：水泥SiO2含量不能为空");
            }
            if (isBlank(cementAl2o3)) {//11
                return AjaxResult.error("第 " + (i + 1) + " 行：cementAl2o3不能为空");

            }

            if (!isNumber(cementStrengthGrade)) {//
                return AjaxResult.error("第 " + (i + 1) + " 行：28天抗压强度(MPa应为数字");
            }

            if (isBlank(cementCompressive)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：水泥强度等级不能为空");
            }


            if (!cementRegionName.matches(regionPattern)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：水泥来源地区不正确，应为“浙江省”或“浙江省-杭州市”或“浙江省-杭州市-余杭区/余杭县”");
            }//14

            /*石头 5-10*/

            if (!isNumber(stone510)) {//15
                return AjaxResult.error("第 " + (i + 1) + " 行:石5-10mm掺量应为数字");
            }

            if (isBlank(model)) {//16
                return AjaxResult.error("第 " + (i + 1) + " 行：石5-10mm型号不能为空");
            }

            if (isBlank(stoneSpecification)) {//16
                return AjaxResult.error("第 " + (i + 1) + " 行：石5-10mm石子规格(mm)不能为空");
            }

            if (!isNumber(stackingDensity)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:石头5-10堆积密度应为数字");
            }
            if (!isNumber(compactDensity)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:石头5-10堆紧密密度应为数字");
            }
            if (!isNumber(bulkdensity)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:石头5-10表观密度应为数字");
            }

            if (!regionNamestone510.matches(regionPattern)) {
                return AjaxResult.error("第 " + (i + 1) + " 行： 石头5-10来源地区不正确，应为“浙江省”或“浙江省-杭州市”或“浙江省-杭州市-余杭区/余杭县”");
            }//21



            /*5-25*/

            if (!isNumber(stone525)) {//15
                return AjaxResult.error("第 " + (i + 1) + " 行:石头5-25掺量应为数字");
            }

            if (isBlank(model525)) {//16
                return AjaxResult.error("第 " + (i + 1) + " 行：石头5-25型号不能为空");
            }

            if (isBlank(stoneSpecification525)) {//16
                return AjaxResult.error("第 " + (i + 1) + " 行：石头5-25石子规格(mm)不能为空");
            }

            if (!isNumber(stackingDensity525)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:石头5-25堆积密度应为数字");
            }
            if (!isNumber(compactDensity525)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:石头5-25堆紧密密度应为数字");
            }
            if (!isNumber(bulkdensity525)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:石头5-25表观密度应为数字");
            }

            if (!regionNamestone525.matches(regionPattern)) {
                return AjaxResult.error("第 " + (i + 1) + " 行： 石头5-25来源地区不正确，应为“浙江省”或“浙江省-杭州市”或“浙江省-杭州市-余杭区/余杭县”");

            }

 /*-------------石头20-40mm---------*/

            if (!isNumber(stone2040)) {//15
                return AjaxResult.error("第 " + (i + 1) + " 行:石头20-40mm掺量应为数字");
            }

            if (isBlank(model2040)) {//16
                return AjaxResult.error("第 " + (i + 1) + " 行：石头20-40mm型号不能为空");
            }

            if (isBlank(stoneSpecification2040)) {//16
                return AjaxResult.error("第 " + (i + 1) + " 行：石头20-40mm石子规格(mm)不能为空");
            }

            if (!isNumber(stackingDensity2040)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:石头20-40mm堆积密度应为数字");
            }
            if (!isNumber(compactDensity2040)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:石头20-40mm堆紧密密度应为数字");
            }
            if (!isNumber(bulkdensity2040)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:石头20-40mm表观密度应为数字");
            }

            if (!regionNamestone2040.matches(regionPattern)) {
                return AjaxResult.error("第 " + (i + 1) + " 行： 石头20-40mm来源地区不正确，应为“浙江省”或“浙江省-杭州市”或“浙江省-杭州市-余杭区/余杭县”");

            }
/* 石头 10-20*/

            if (!isNumber(stone1020)) {//15
                return AjaxResult.error("第 " + (i + 1) + " 行:石头10-20mm掺量应为数字");
            }

            if (isBlank(model1020)) {//16
                return AjaxResult.error("第 " + (i + 1) + " 行：石头10-20mm型号不能为空");
            }

            if (isBlank(stoneSpecification1020)) {//16
                return AjaxResult.error("第 " + (i + 1) + " 行：石头10-20mm石子规格(mm)不能为空");
            }

            if (!isNumber(stackingDensity1020)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:石头10-20mm堆积密度应为数字");
            }
            if (!isNumber(compactDensity1020)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:石头10-20mm堆紧密密度应为数字");
            }
            if (!isNumber(bulkdensity1020)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:石头10-20mm表观密度应为数字");
            }

            if (!regionNamestone1020.matches(regionPattern)) {
                return AjaxResult.error("第 " + (i + 1) + " 行： 石头10-20mm来源地区不正确，应为“浙江省”或“浙江省-杭州市”或“浙江省-杭州市-余杭区/余杭县”");

            }

/*石头10-30*/

            if (!isNumber(stone1030)) {//15
                return AjaxResult.error("第 " + (i + 1) + " 行:石头10-30mm掺量应为数字");
            }

            if (isBlank(model1030)) {//16
                return AjaxResult.error("第 " + (i + 1) + " 行：石头10-30mm型号不能为空");
            }

            if (isBlank(stoneSpecification1030)) {//16
                return AjaxResult.error("第 " + (i + 1) + " 行：石头10-30mm石子规格(mm)不能为空");
            }

            if (!isNumber(stackingDensity1030)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:石头10-30mm堆积密度应为数字");
            }
            if (!isNumber(compactDensity1030)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:石头10-30mm堆紧密密度应为数字");
            }
            if (!isNumber(bulkdensity1030)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:石头10-30mm表观密度应为数字");
            }

            if (!regionNamestone1030.matches(regionPattern)) {
                return AjaxResult.error("第 " + (i + 1) + " 行： 石头10-30mm来源地区不正确，应为“浙江省”或“浙江省-杭州市”或“浙江省-杭州市-余杭区/余杭县”");

            }


            /*石头 0-10*/

            if (!isNumber(stone010)) {//15
                return AjaxResult.error("第 " + (i + 1) + " 行:石头0-10mm掺量应为数字");
            }

            if (isBlank(model010)) {//16
                return AjaxResult.error("第 " + (i + 1) + " 行：石头0-10mm型号不能为空");
            }

            if (isBlank(stoneSpecification010)) {//16
                return AjaxResult.error("第 " + (i + 1) + " 行：石头0-10mm石子规格(mm)不能为空");
            }

            if (!isNumber(stackingDensity010)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:石头0-10mm堆积密度应为数字");
            }
            if (!isNumber(compactDensity010)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:石头0-10mm堆紧密密度应为数字");
            }
            if (!isNumber(bulkdensity010)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:石头0-10mm表观密度应为数字");
            }

            if (!regionNamestone010.matches(regionPattern)) {
                return AjaxResult.error("第 " + (i + 1) + " 行： 石头0-10mm来源地区不正确，应为“浙江省”或“浙江省-杭州市”或“浙江省-杭州市-余杭区/余杭县”");

            }
/*石头20-31.5mm*/

            if (!isNumber(stone20315)) {//15
                return AjaxResult.error("第 " + (i + 1) + " 行:石头20-31.5mm掺量应为数字");
            }

            if (isBlank(model20315)) {//16
                return AjaxResult.error("第 " + (i + 1) + " 行：石头20-31.5mm型号不能为空");
            }

            if (isBlank(stoneSpecification20315)) {//16
                return AjaxResult.error("第 " + (i + 1) + " 行：石头20-31.5mm石子规格(mm)不能为空");
            }

            if (!isNumber(stackingDensity20315)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:石头20-31.5mm堆积密度应为数字");
            }
            if (!isNumber(compactDensity20315)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:石头20-31.5mm堆紧密密度应为数字");
            }
            if (!isNumber(bulkdensity20315)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:石头20-31.5mm表观密度应为数字");
            }

            if (!regionNamestone20315.matches(regionPattern)) {
                return AjaxResult.error("第 " + (i + 1) + " 行： 石头20-31.5mm来源地区不正确，应为“浙江省”或“浙江省-杭州市”或“浙江省-杭州市-余杭区/余杭县”");

            }

            /*河砂粗3.1-3.7mm*/
            if (!isNumber(sand3137)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:河砂粗3.1-3.7mm掺量应为数字");
            }

            if (isBlank(model3137)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：河砂粗3.1-3.7mm型号不能为空");
            }

            if (!isNumber(fineness3137)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:河砂粗3.1-3.7mm细度应为数字");
            }

            if (!isNumber(bulkDensity3137)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:河砂粗3.1-3.7mm堆积密度应为数字");
            }
            if (!isNumber(compactDensity3137)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:河砂粗3.1-3.7mm紧密密度为数字");
            }
            if (!isNumber(apparentDensity3137)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:河砂粗3.1-3.7mm表观密度应为数字");
            }

            if (isBlank(particleSizeDistribution3137)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：河砂粗3.1-3.7mm粒径分布不能为空");
            }

            if (!regionSandName3137.matches(regionPattern)) {
                return AjaxResult.error("第 " + (i + 1) + " 行： 河砂粗3.1-3.7mm来源地区不正确，应为“浙江省”或“浙江省-杭州市”或“浙江省-杭州市-余杭区/余杭县”");

            }

            /*河砂粗砂23-30*/
            if (!isNumber(sand2330)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:河砂粗23-30mm掺量应为数字");
            }

            if (isBlank(model2330)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：河砂粗23-30mm型号不能为空");
            }

            if (!isNumber(fineness2330)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:河砂粗23-30mm细度应为数字");
            }

            if (!isNumber(bulkDensity2330)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:河砂粗23-30mm堆积密度应为数字");
            }
            if (!isNumber(compactDensity2330)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:河砂粗23-30mm紧密密度为数字");
            }
            if (!isNumber(apparentDensity2330)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:河砂粗23-30mm表观密度应为数字");
            }

            if (isBlank(particleSizeDistribution2330)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：河砂粗23-30mm粒径分布不能为空");
            }

            if (!regionSandName2330.matches(regionPattern)) {
                return AjaxResult.error("第 " + (i + 1) + " 行： 河砂粗23-30mm来源地区不正确，应为“浙江省”或“浙江省-杭州市”或“浙江省-杭州市-余杭区/余杭县”");

            }

            /*河砂细16-22mm*/
            if (!isNumber(sand1622)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:河砂细16-22mm掺量应为数字");
            }

            if (isBlank(model1622)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：河砂细16-22mm型号不能为空");
            }

            if (!isNumber(fineness1622)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:河砂细16-22mm细度应为数字");
            }

            if (!isNumber(bulkDensity1622)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:河砂细16-22mm堆积密度应为数字");
            }
            if (!isNumber(compactDensity1622)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:河砂细16-22mm紧密密度为数字");
            }
            if (!isNumber(apparentDensity1622)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:河砂细16-22mm表观密度应为数字");
            }

            if (isBlank(particleSizeDistribution1622)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：河砂细16-22mm粒径分布不能为空");
            }

            if (!regionSandName1622.matches(regionPattern)) {
                return AjaxResult.error("第 " + (i + 1) + " 行： 河砂细16-22mm来源地区不正确，应为“浙江省”或“浙江省-杭州市”或“浙江省-杭州市-余杭区/余杭县”");

            }
/*机制砂中23-30Bmm*/

            if (!isNumber(sand2330B)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:机制砂中23-30mm掺量应为数字");
            }

            if (isBlank(model2330B)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：机制砂中23-30mm型号不能为空");
            }

            if (!isNumber(fineness2330B)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:机制砂中23-30mm细度应为数字");
            }

            if (!isNumber(bulkDensity2330B)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:机制砂中23-30mm堆积密度应为数字");
            }
            if (!isNumber(compactDensity2330B)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:机制砂中23-30mm紧密密度为数字");
            }
            if (!isNumber(apparentDensity2330B)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:机制砂中23-30mm表观密度应为数字");
            }

            if (isBlank(particleSizeDistribution2330B)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：机制砂中23-30mm粒径分布不能为空");
            }

            if (!regionSandName2330B.matches(regionPattern)) {
                return AjaxResult.error("第 " + (i + 1) + " 行： 机制砂中23-30mm来源地区不正确，应为“浙江省”或“浙江省-杭州市”或“浙江省-杭州市-余杭区/余杭县”");

            }
            /*机制砂粗31-37Bmm*/

            if (!isNumber(sand3137B)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:机制砂粗31-37mm掺量应为数字");
            }

            if (isBlank(model3137B)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：机制砂粗31-37mm型号不能为空");
            }

            if (!isNumber(fineness3137B)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:机制砂粗31-37mm细度应为数字");
            }

            if (!isNumber(bulkDensity3137B)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:机制砂粗31-37mm堆积密度应为数字");
            }
            if (!isNumber(compactDensity3137B)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:机制砂粗31-37mm紧密密度为数字");
            }
            if (!isNumber(apparentDensity3137B)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:机制砂粗31-37mm表观密度应为数字");
            }

            if (isBlank(particleSizeDistribution3137B)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：机制砂粗31-37mm粒径分布不能为空");
            }

            if (!regionSandName3137B.matches(regionPattern)) {
                return AjaxResult.error("第 " + (i + 1) + " 行： 机制砂粗31-37mm来源地区不正确，应为“浙江省”或“浙江省-杭州市”或“浙江省-杭州市-余杭区/余杭县”");

            }
/*机制砂细16-22Bmm*/
            if (!isNumber(sand1622B)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:机制砂细16-22mm掺量应为数字");
            }

            if (isBlank(model1622B)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：机制砂细16-22mm型号不能为空");
            }

            if (!isNumber(fineness1622B)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:机制砂细16-22mm细度应为数字");
            }

            if (!isNumber(bulkDensity1622B)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:机制砂细16-22mm堆积密度应为数字");
            }
            if (!isNumber(compactDensity1622B)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:机制砂细16-22mm紧密密度为数字");
            }
            if (!isNumber(apparentDensity1622B)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:机制砂细16-22mm表观密度应为数字");
            }

            if (isBlank(particleSizeDistribution1622B)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：机制砂细16-22mm粒径分布不能为空");
            }

            if (!regionSandName1622B.matches(regionPattern)) {
                return AjaxResult.error("第 " + (i + 1) + " 行： 机制砂细16-22mm来源地区不正确，应为“浙江省”或“浙江省-杭州市”或“浙江省-杭州市-余杭区/余杭县”");

            }

            /*机制砂0-4.75mm*/


            if (!isNumber(sand0475)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:机制砂0-4.75mm掺量应为数字");
            }

            if (isBlank(model0475)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：机制砂0-4.75mm型号不能为空");
            }

            if (!isNumber(fineness0475)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:机制砂0-4.75mm细度应为数字");
            }

            if (!isNumber(bulkDensity0475)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:机制砂0-4.75mm堆积密度应为数字");
            }
            if (!isNumber(compactDensity0475)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:机制砂0-4.75mm紧密密度为数字");
            }
            if (!isNumber(apparentDensity0475)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:机制砂0-4.75mm表观密度应为数字");
            }

            if (isBlank(particleSizeDistribution0475)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：机制砂0-4.75mm粒径分布不能为空");
            }

            if (!regionSandName0475.matches(regionPattern)) {
                return AjaxResult.error("第 " + (i + 1) + " 行： 机制砂0-4.75mm来源地区不正确，应为“浙江省”或“浙江省-杭州市”或“浙江省-杭州市-余杭区/余杭县”");

            }


            /*机制砂0-9mm*/


            if (!isNumber(sand09)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:机制砂0-9mm掺量应为数字");
            }

            if (isBlank(model09)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：机制砂0-9mm型号不能为空");
            }

            if (!isNumber(fineness09)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:机制砂0-9mm细度应为数字");
            }

            if (!isNumber(bulkDensity09)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:机制砂0-9mm堆积密度应为数字");
            }
            if (!isNumber(compactDensity09)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:机制砂0-9mm紧密密度为数字");
            }
            if (!isNumber(apparentDensity09)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:机制砂0-9mm表观密度应为数字");
            }

            if (isBlank(particleSizeDistribution09)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：机制砂0-9mm粒径分布不能为空");
            }

            if (!regionSandName09.matches(regionPattern)) {
                return AjaxResult.error("第 " + (i + 1) + " 行： 机制砂0-9mm来源地区不正确，应为“浙江省”或“浙江省-杭州市”或“浙江省-杭州市-余杭区/余杭县”");

            }

            /*石粉*/
            if (!isNumber(otherAdmixtures)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:石粉掺量应为数字");
            }

            if (isBlank(modelotherAdmixtures)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：石粉型号不能为空");
            }

            if (!isNumber(finenessotherAdmixtures)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:石粉细度应为数字");
            }

            if (!isNumber(moistureContentotherAdmixtures)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:石粉含水量(%)应为数字");
            }
            if (!isNumber(activityIndex28dOtherAdmixtures)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:石粉28天活性指数(%)应为数字");
            }

            if (!regionNameOtherAdmixtures.matches(regionPattern)) {
                return AjaxResult.error("第 " + (i + 1) + " 行： 石粉来源地区不正确，应为“浙江省”或“浙江省-杭州市”或“浙江省-杭州市-余杭区/余杭县”");

            }
            /*矿粉*/
            if (!isNumber(mineralPowder)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:矿粉掺量应为数字");
            }

            if (isBlank(mineralPowdermodel)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：矿粉型号不能为空");
            }

            if (isBlank(mineralPowderSlagGrade)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：矿粉等级不能为空");
            }

            if (!isNumber(mineralPowderFineness)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:石粉细度应为数字");
            }

            if (!isNumber(mineralPowdermoistureContent)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:矿粉含水量(%)应为数字");
            }
            if (!isNumber(mineralPowderactivityIndex28d)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:矿粉28天活性指数(%)应为数字");
            }

            if (!mineralPowderregionName.matches(regionPattern)) {
                return AjaxResult.error("第 " + (i + 1) + " 行： 矿粉来源地区不正确，应为“浙江省”或“浙江省-杭州市”或“浙江省-杭州市-余杭区/余杭县”");

            }
            /*粉煤灰*/
            if (!isNumber(sysFlyash)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:粉煤灰掺量应为数字");
            }

            if (isBlank(flyashModel)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：粉煤灰型号不能为空");
            }
            if (isBlank(flyashFactoryGrade)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：粉煤灰出厂等级");
            }

            if (!isNumber(flyashFineness)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:粉煤灰细度应为数字");
            }

            if (!isNumber(flyashMoistureContent)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:粉煤灰含水量(%)应为数字");
            }
            if (!isNumber(flyashActivityIndex28d)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:粉煤灰28天活性指数(%)应为数字");
            }

            if (!flyashRegionName.matches(regionPattern)) {
                return AjaxResult.error("第 " + (i + 1) + " 行： 粉煤灰来源地区不正确，应为“浙江省”或“浙江省-杭州市”或“浙江省-杭州市-余杭区/余杭县”");

            }

/*减水剂*/
            if (!isNumber(waterReducer)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:减水剂掺量应为数字");
            }

            if (isBlank(waterReducerModel)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：减水剂型号不能为空");
            }


            if (!isNumber(waterReducersolidContent)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:减水剂含固量应为数字");
            }

            if (!isNumber(waterReducercementPasteFlow)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:减水剂水泥净浆流动度(mm)应为数字");
            }
            if (!isNumber(waterReducerreducingRate)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:减水剂减水率应为数字");
            }




            if (isBlank(waterReducerRegionName)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：减水剂商家不能为空");
            }


            /*增效剂*/
            if (!isNumber(efficiencyAgent)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:增效剂掺量应为数字");
            }

            if (isBlank(efficiencyAgentModel)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：增效剂型号不能为空");
            }


            if (isBlank(efficiencyAgentName)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：增效剂商家不能为空");
            }

            /*膨胀剂*/
            if (!isNumber(swellingagentAgent)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:膨胀剂掺量应为数字");
            }

            if (isBlank(swellingagentModel)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：膨胀剂型号不能为空");
            }



            if (isBlank(swellingagentName)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：膨胀剂商家不能为空");
            }





            Region matched = matchOrInsertRegion(region, fullNameMap);
            if (matched == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(0, String.valueOf(matched.getId()));

            Region matched14 = matchOrInsertRegion(cementRegionName, fullNameMap);
            if (matched14 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(14, String.valueOf(matched14.getId()));

            Region matchedregionNamestone510 = matchOrInsertRegion(regionNamestone510, fullNameMap);
            if (matchedregionNamestone510 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(21, String.valueOf(matchedregionNamestone510.getId()));

            Region matchedregionNamestone525 = matchOrInsertRegion(regionNamestone525, fullNameMap);
            if (matchedregionNamestone525 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(28, String.valueOf(matchedregionNamestone525.getId()));


            Region matchedregionNamestone2040 = matchOrInsertRegion(regionNamestone2040, fullNameMap);
            if (matchedregionNamestone2040 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(35, String.valueOf(matchedregionNamestone2040.getId()));


            Region matchedregionNamestone1020 = matchOrInsertRegion(regionNamestone1020, fullNameMap);
            if (matchedregionNamestone1020 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(42, String.valueOf(matchedregionNamestone1020.getId()));


            Region matchedregionNamestone1030 = matchOrInsertRegion(regionNamestone1030, fullNameMap);
            if (matchedregionNamestone1020 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(49, String.valueOf(matchedregionNamestone1030.getId()));

            Region matchedregionNamestone010 = matchOrInsertRegion(regionNamestone010, fullNameMap);
            if (matchedregionNamestone010 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(56, String.valueOf(matchedregionNamestone010.getId()));


            Region matchedregionNamestone20315 = matchOrInsertRegion(regionNamestone20315, fullNameMap);
            if (matchedregionNamestone20315 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(63, String.valueOf(matchedregionNamestone20315.getId()));


            Region SandName3137 = matchOrInsertRegion(regionSandName3137, fullNameMap);
            if (SandName3137 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(71, String.valueOf(SandName3137.getId()));


            Region SandName2330 = matchOrInsertRegion(regionSandName2330, fullNameMap);
            if (SandName2330 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(79, String.valueOf(SandName2330.getId()));


            Region SandName1622 = matchOrInsertRegion(regionSandName1622, fullNameMap);
            if (SandName1622 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(87, String.valueOf(SandName1622.getId()));

            Region SandName2330B = matchOrInsertRegion(regionSandName2330B, fullNameMap);
            if (SandName2330B == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(95, String.valueOf(SandName2330B.getId()));


            Region SandName3137B = matchOrInsertRegion(regionSandName3137B, fullNameMap);
            if (SandName3137B == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(103, String.valueOf(SandName3137B.getId()));

            Region SandName1622B = matchOrInsertRegion(regionSandName1622B, fullNameMap);
            if (SandName1622B == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(111, String.valueOf(SandName1622B.getId()));


            Region SandName0475 = matchOrInsertRegion(regionSandName0475, fullNameMap);
            if (SandName0475 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(119, String.valueOf(SandName0475.getId()));


            Region SandName09 = matchOrInsertRegion(regionSandName09, fullNameMap);
            if (SandName09 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(127, String.valueOf(SandName09.getId()));


            Region SandName133 = matchOrInsertRegion(regionNameOtherAdmixtures, fullNameMap);
            if (SandName133 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(133, String.valueOf(SandName133.getId()));

            Region SandName140 = matchOrInsertRegion(mineralPowderregionName, fullNameMap);
            if (SandName140 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(140, String.valueOf(SandName140.getId()));


            Region SandName147 = matchOrInsertRegion(flyashRegionName, fullNameMap);
            if (SandName147 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(147, String.valueOf(SandName147.getId()));


        }
        return AjaxResult.success("水泥数据校验通过，地区已处理");
    }


    private AjaxResult checkDurabilityPerformance(List<List<String>> data) {
        return null;
    }

    //校验变形性能性能表                         8：变形性能
    private AjaxResult checkDeformationPerformance(List<List<String>> data) {
        return null;

    }


    //校验耐久性能性能性能表                      10：水
    private AjaxResult checkWaterPerformance(List<List<String>> data) {

        // 校验 data 中每个元素的格式
        for (List<String> item : data) {

            //第一个是文字

            //第二个是数字

        }
        return AjaxResult.success();
    }


    /*校验矿粉 11：矿粉*/
    private AjaxResult checkMineralPowderformance(List<List<String>> data) {

        if (data == null || data.size() <= 1) {
            return AjaxResult.error("请上传包含至少一条数据的文件");
        }

        // 校验之前去掉表头列
        data.remove(0); // 去掉表头

        // 查询所有未删除的地区
        LambdaQueryWrapper<Region> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Region::getDeleteTime, 0);
        List<Region> regionList = regionService.list(wrapper);

        // 构建 fullName -> Region 的 Map
        Map<String, Region> fullNameMap = new HashMap<>();
        for (Region r : regionList) {
            fullNameMap.put(r.getFullName(), r);
        }

        for (int i = 0; i < data.size(); i++) {

            System.out.println("我是data数据" + data);


            List<String> row = data.get(i);
            if (row == null || row.size() != 6) {
                return AjaxResult.error("第 " + (i + 1) + " 行：必须包含 6 个字段");
            }

            String model = row.get(0); //型号
            String slagGrade = row.get(1);//矿粉等级

            String fineness = row.get(2);//细度
            String moistureContent = row.get(3);//含水量
            String activityIndex28d = row.get(4);//28天活性指数
            String regionName = row.get(5);//来源地区


            if (isBlank(model)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：型号不能为空");
            }
            if (isBlank(slagGrade)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：矿粉等级不能为空");
            }
            if (!isNumber(fineness)) {
                return AjaxResult.error("第 " + (i + 1) + "行：细度应为数字");
            }
            if (!isNumber(moistureContent)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：含水量应为数字");
            }

            if (!isNumber(activityIndex28d)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：28天活性指数应为数字");
            }

            if (isBlank(regionName)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区不能为空");
            }

            String regionPattern = "^([\\u4e00-\\u9fa5]{2,}(省|市))?(?:-[\\u4e00-\\u9fa5]{2,}(市|州|盟|区|县))?(?:-[\\u4e00-\\u9fa5]{2,}(市|区|县|旗))?$";

            if (!regionName.matches(regionPattern)) {
                return AjaxResult.error("地区格式不正确，应为“浙江省”、“浙江省-杭州市”、“浙江省-杭州市-余杭区”等格式");
            }




            Region matched = matchOrInsertRegion(regionName, fullNameMap);
            if (matched == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + regionName);
            }
            row.set(5, String.valueOf(matched.getId()));
        }

        return AjaxResult.success("水泥数据校验通过，地区已处理");

    }


    //校验耐久性能性能性能表                    12：石粉
    private AjaxResult checkOtherAdmixturesformance(List<List<String>> data) {

        if (data == null || data.size() <= 1) {
            return AjaxResult.error("请上传包含至少一条数据的文件");
        }

        // 校验之前去掉表头列
        data.remove(0); // 去掉表头

        // 查询所有未删除的地区
        LambdaQueryWrapper<Region> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Region::getDeleteTime, 0);
        List<Region> regionList = regionService.list(wrapper);

        // 构建 fullName -> Region 的 Map
        Map<String, Region> fullNameMap = new HashMap<>();
        for (Region r : regionList) {
            fullNameMap.put(r.getFullName(), r);
        }

        for (int i = 0; i < data.size(); i++) {

            System.out.println("我是data数据" + data);


            List<String> row = data.get(i);
            if (row == null || row.size() != 5) {
                return AjaxResult.error("第 " + (i + 1) + " 行：必须包含 5 个字段");
            }

            String model = row.get(0); //型号

            String fineness = row.get(1);//细度(%)
            String moistureContent = row.get(2);//含水量(%)
            String activityIndex28d = row.get(3);//28天活性指数(%)

            String regionName = row.get(4);//来源地区


            if (isBlank(model)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：型号不能为空");
            }

            if (!isNumber(fineness)) {
                return AjaxResult.error("第 " + (i + 1) + "行：细度应为数字");
            }
            if (!isNumber(moistureContent)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：含水量应为数字");
            }

            if (!isNumber(activityIndex28d)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：28天活性指数应为数字");
            }

            if (isBlank(regionName)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区不能为空");
            }
            String regionPattern = "^([\\u4e00-\\u9fa5]{2,}(省|市))?(?:-[\\u4e00-\\u9fa5]{2,}(市|州|盟|区|县))?(?:-[\\u4e00-\\u9fa5]{2,}(市|区|县|旗))?$";

            if (!regionName.matches(regionPattern)) {
                return AjaxResult.error("地区格式不正确，应为“浙江省”、“浙江省-杭州市”、“浙江省-杭州市-余杭区”等格式");
            }


            Region matched = matchOrInsertRegion(regionName, fullNameMap);
            if (matched == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + regionName);
            }
            row.set(4, String.valueOf(matched.getId()));
        }

        return AjaxResult.success("水泥数据校验通过，地区已处理");

    }


    //  13：膨胀剂
    private AjaxResult checkSwellingagentAdmixturesformance(List<List<String>> data) {
        if (data == null || data.size() <= 1) {
            return AjaxResult.error("请上传包含至少一条数据的文件");
        }

        // 校验之前去掉表头列
        data.remove(0); // 去掉表头


        for (int i = 0; i < data.size(); i++) {

            System.out.println("我是data数据" + data);


            List<String> row = data.get(i);
            if (row == null || row.size() != 2) {
                return AjaxResult.error("第 " + (i + 1) + " 行：必须包含 2 个字段");
            }

            String model = row.get(0);//型号
            String regionName = row.get(1);//来源


            if (isBlank(model)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：型号不能为空");
            }

            if (isBlank(regionName)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：来源不能为空");
            }


        }
        return AjaxResult.success("增效剂校验通过");


    }


    //校验坍落度表     14：坍落度
    private AjaxResult checkSysSlump(List<List<String>> data) {
        if (data == null || data.size() <= 1) {
            return AjaxResult.error("请上传包含至少一条数据的文件");
        }
        // 校验之前去掉表头列
        data.remove(0); // 去掉表头

        // 查询所有未删除的地区
        LambdaQueryWrapper<Region> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Region::getDeleteTime, 0);
        List<Region> regionList = regionService.list(wrapper);


        // 构建 fullName -> Region 的 Map
        Map<String, Region> fullNameMap = new HashMap<>();
        for (Region r : regionList) {
            fullNameMap.put(r.getFullName(), r);
        }

        for (int i = 0; i < data.size(); i++) {
            System.out.println("我是data数据" + data);

            List<String> row = data.get(i);

//            if (row == null || row.size() != 22) {
//                return AjaxResult.error("第 " + (i + 1) + " 行：必须包含 22个字段");
//            }

            String region = row.get(0); //地区
            String productionDate = row.get(1);//生产日期
            String slump = row.get(2);//坍落度

//            String strengthGrade = row.get(2);//强度等级
//            String compressive3d = row.get(3);//3天抗压强度(MPa)
//            String compressive7d = row.get(4);//7天抗压强度(MPa)
//            String compressive28d = row.get(5);//28天抗压强度(MPa)

            String water = row.get(6);//水掺量(kg/m³)
            String cement = row.get(7);//水泥掺量(kg/m³)

            /*水泥*/
            String cementModel = row.get(8);//水泥型号
            String cementCao = row.get(9);//水泥CaO含量
            String cementSio2 = row.get(10);//水泥SiO2含量
            String cementAl2o3 = row.get(11);//水泥Al2O3含量

            String cementStrengthGrade = row.get(12);// 强度等级
            String cementCompressive = row.get(13);//28天

//            String cementCompressive = row.get(12);//强度等级
//            String cementStrengthGrade = row.get(13);//28天


            String cementRegionName = row.get(14);//水泥地区


            String stone510 = row.get(15); //掺量  石头5-10
            String model = row.get(16); //型号  石头5-10
            String stoneSpecification = row.get(17);//石子规格   石头5-10
            String stackingDensity = row.get(18);//堆积密度    石头5-10
            String compactDensity = row.get(19);//紧密密度  石头5-10
            String bulkdensity = row.get(20);//表观密度      石头5-10
            String regionNamestone510 = row.get(21);//来源地区      石头5-10


            String stone525 = row.get(22); //掺量  石头5-25
            String model525 = row.get(23); //型号  石头5-25
            String stoneSpecification525 = row.get(24);//石子规格   石头5-25
            String stackingDensity525 = row.get(25);//堆积密度    石头5-25
            String compactDensity525 = row.get(26);//紧密密度  石头5-25
            String bulkdensity525 = row.get(27);//表观密度      石头5-25
            String regionNamestone525 = row.get(28);//来源地区      石头5-25


            String stone2040 = row.get(29); //掺量  石头20-40mm
            String model2040 = row.get(30); //型号  石头20-40mm
            String stoneSpecification2040 = row.get(31);//石子规格   石头20-40mm
            String stackingDensity2040 = row.get(32);//堆积密度    石头20-40mm
            String compactDensity2040 = row.get(33);//紧密密度  石头20-40mm
            String bulkdensity2040 = row.get(34);//表观密度      石头20-40mm
            String regionNamestone2040 = row.get(35);//来源地区      石头20-40mm


            String stone1020 = row.get(36); //掺量  石头20-40mm
            String model1020 = row.get(37); //型号  石头20-40mm
            String stoneSpecification1020 = row.get(38);//石子规格   石头20-40mm
            String stackingDensity1020 = row.get(39);//堆积密度    石头20-40mm
            String compactDensity1020 = row.get(40);//紧密密度  石头20-40mm
            String bulkdensity1020 = row.get(41);//表观密度      石头20-40mm
            String regionNamestone1020 = row.get(42);//来源地区      石头20-40mm


            String stone1030 = row.get(43); //掺量  石头10-30mm
            String model1030 = row.get(44); //型号  石头10-30mm
            String stoneSpecification1030 = row.get(45);//石子规格   石头10-30mm
            String stackingDensity1030 = row.get(46);//堆积密度    石头10-30mm
            String compactDensity1030 = row.get(47);//紧密密度  石头10-30mm
            String bulkdensity1030 = row.get(48);//表观密度      石头10-30mm
            String regionNamestone1030 = row.get(49);//来源地区      石头10-30mm


            String stone010 = row.get(50); //掺量  石头0-10mm
            String model010 = row.get(51); //型号  石头10-30mm
            String stoneSpecification010 = row.get(52);//石子规格   石头10-30mm
            String stackingDensity010 = row.get(53);//堆积密度    石头10-30mm
            String compactDensity010 = row.get(54);//紧密密度  石头10-30mm
            String bulkdensity010 = row.get(55);//表观密度      石头10-30mm
            String regionNamestone010 = row.get(56);//来源地区      石头10-30mm


            String stone20315 = row.get(57); //掺量  石头0-10mm
            String model20315 = row.get(58); //型号  石头10-30mm
            String stoneSpecification20315 = row.get(59);//石子规格   石头10-30mm
            String stackingDensity20315 = row.get(60);//堆积密度    石头10-30mm
            String compactDensity20315 = row.get(61);//紧密密度  石头10-30mm
            String bulkdensity20315 = row.get(62);//表观密度      石头10-30mm
            String regionNamestone20315 = row.get(63);//来源地区      石头10-30mm





            /*河砂粗3.1-3.7mm*/
            String sand3137 = row.get(64);//砂掺量

            String model3137 = row.get(65);//型号
            String fineness3137 = row.get(66);//细度
            String bulkDensity3137 = row.get(67);//堆积密度 (kg/m3)
            String compactDensity3137 = row.get(68);//紧密密度 (kg/m3)
            String apparentDensity3137 = row.get(69);//表观密度 (kg/m3)

            String particleSizeDistribution3137 = row.get(70);//粒径分布(mm)
            String regionSandName3137 = row.get(71);



            /*河砂粗砂23-30*/
            String sand2330 = row.get(72);//砂掺量

            String model2330 = row.get(73);//型号
            String fineness2330 = row.get(74);//细度
            String bulkDensity2330 = row.get(75);//堆积密度 (kg/m3)
            String compactDensity2330 = row.get(76);//紧密密度 (kg/m3)
            String apparentDensity2330 = row.get(77);//表观密度 (kg/m3)
            String particleSizeDistribution2330 = row.get(78);//粒径分布(mm)
            String regionSandName2330 = row.get(79);



            /*河砂细16-22mm*/
            String sand1622 = row.get(80);//砂掺量

            String model1622 = row.get(81);//型号
            String fineness1622 = row.get(82);//细度
            String bulkDensity1622 = row.get(83);//堆积密度 (kg/m3)
            String compactDensity1622 = row.get(84);//紧密密度 (kg/m3)
            String apparentDensity1622 = row.get(85);//表观密度 (kg/m3)
            String particleSizeDistribution1622 = row.get(86);//粒径分布(mm)
            String regionSandName1622 = row.get(87);



            /*机制砂中23-30Bmm*/
            String sand2330B = row.get(88);//砂掺量

            String model2330B = row.get(89);//型号
            String fineness2330B = row.get(90);//细度
            String bulkDensity2330B = row.get(91);//堆积密度 (kg/m3)
            String compactDensity2330B = row.get(92);//紧密密度 (kg/m3)
            String apparentDensity2330B = row.get(93);//表观密度 (kg/m3)
            String particleSizeDistribution2330B = row.get(94);//粒径分布(mm)
            String regionSandName2330B = row.get(95);




            /*机制砂粗31-37Bmm*/
            String sand3137B = row.get(96);//砂掺量
            String model3137B = row.get(97);//型号
            String fineness3137B = row.get(98);//细度
            String bulkDensity3137B = row.get(99);//堆积密度 (kg/m3)
            String compactDensity3137B = row.get(100);//紧密密度 (kg/m3)
            String apparentDensity3137B = row.get(101);//表观密度 (kg/m3)
            String particleSizeDistribution3137B = row.get(102);//粒径分布(mm)
            String regionSandName3137B = row.get(103);


            /*机制砂细16-22Bmm*/
            String sand1622B = row.get(104);//砂掺量
            String model1622B = row.get(105);//型号
            String fineness1622B = row.get(106);//细度
            String bulkDensity1622B = row.get(107);//堆积密度 (kg/m3)
            String compactDensity1622B = row.get(108);//紧密密度 (kg/m3)
            String apparentDensity1622B = row.get(109);//表观密度 (kg/m3)
            String particleSizeDistribution1622B = row.get(110);//粒径分布(mm)
            String regionSandName1622B = row.get(111);


            /*机制砂0-4.75mm*/
            String sand0475 = row.get(112);//砂掺量
            String model0475 = row.get(113);//型号
            String fineness0475 = row.get(114);//细度
            String bulkDensity0475 = row.get(115);//堆积密度 (kg/m3)
            String compactDensity0475 = row.get(116);//紧密密度 (kg/m3)
            String apparentDensity0475 = row.get(117);//表观密度 (kg/m3)
            String particleSizeDistribution0475 = row.get(118);//粒径分布(mm)
            String regionSandName0475 = row.get(119);




            /*机制砂0-9mm*/
            String sand09 = row.get(120);//砂掺量
            String model09 = row.get(121);//型号
            String fineness09 = row.get(122);//细度
            String bulkDensity09 = row.get(123);//堆积密度 (kg/m3)
            String compactDensity09 = row.get(124);//紧密密度 (kg/m3)
            String apparentDensity09 = row.get(125);//表观密度 (kg/m3)
            String particleSizeDistribution09 = row.get(126);//粒径分布(mm)
            String regionSandName09 = row.get(127);


            /*石粉*/
            String otherAdmixtures = row.get(128); //掺量
            String modelotherAdmixtures = row.get(129); //型号
            String finenessotherAdmixtures = row.get(130);//细度(%)
            String moistureContentotherAdmixtures = row.get(131);//含水量(%)
            String activityIndex28dOtherAdmixtures = row.get(132);//28天活性指数(%)
            String regionNameOtherAdmixtures = row.get(133);//来源地区



            /*矿粉*/


            String mineralPowder = row.get(134); //矿粉掺量

            String mineralPowdermodel = row.get(135); //型号
            String mineralPowderSlagGrade = row.get(136);//矿粉等级
            String mineralPowderFineness = row.get(137);//细度
            String mineralPowdermoistureContent = row.get(138);//含水量
            String mineralPowderactivityIndex28d = row.get(139);//28天活性指数
            String mineralPowderregionName = row.get(140);//来源地区


            String sysFlyash = row.get(141); //粉煤灰掺量

            String flyashModel = row.get(142); //粉煤灰型号
            String flyashFactoryGrade = row.get(143); //粉煤灰出厂等级
            String flyashFineness = row.get(144);//粉煤灰细度(%)
            String flyashMoistureContent = row.get(145);//粉煤灰含水量(%
            String flyashActivityIndex28d = row.get(146);//粉煤灰28天活性指数(%)
            String flyashRegionName = row.get(147);//粉煤灰来源地区


            String waterReducer = row.get(148);//减水剂掺量
            String waterReducerModel = row.get(149);//减水剂型号
            String waterReducersolidContent = row.get(150);//减水剂含固量(%)
            String waterReducercementPasteFlow = row.get(151);//减水剂水泥净浆流动度(mm)
            String waterReducerreducingRate = row.get(152);//减水剂减水率
            String waterReducerRegionName = row.get(153);//减水剂来源


            String efficiencyAgent = row.get(154);//增效剂掺量
            String efficiencyAgentModel = row.get(155);//增效剂型号
            String efficiencyAgentName = row.get(156);//增效剂来源


            String swellingagentAgent = row.get(157);//膨胀剂掺量
            String swellingagentModel = row.get(158);//膨胀剂型号
            String swellingagentName = row.get(159);//膨胀剂来源




            if (isBlank(region)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：型号不能为空");
            }


           // String regionPattern = "^([\\u4e00-\\u9fa5]{2,}(省|市))(-[\\u4e00-\\u9fa5]+市)?(-[\\u4e00-\\u9fa5]+(区|县))?$";
            String regionPattern = "^([\\u4e00-\\u9fa5]{2,}(省|市))?(?:-[\\u4e00-\\u9fa5]{2,}(市|州|盟|区|县))?(?:-[\\u4e00-\\u9fa5]{2,}(市|区|县|旗))?$";
            if (!region.matches(regionPattern)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区格式不正确，应为“浙江省”或“浙江省-杭州市”或“浙江省-杭州市-余杭区”或“北京”或“北京市”");
            }

            if (isBlank(productionDate)) {//1
                return AjaxResult.error("第 " + (i + 1) + " 行：生产日期为空");
            }

            DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
            try {
                LocalDate.parse(productionDate, formatter);  // 如果不是指定格式会抛异常
            } catch (DateTimeParseException e) {
                return AjaxResult.error("第 " + (i + 1) + " 行：生产日期格式不正确，应为 yyyy-MM-dd，如 2025-04-07");
            }



            if (!isNumber(slump)) {//6
                return AjaxResult.error("第 " + (i + 1) + " 行：坍落度应为数字");
            }




            if (!isNumber(water)) {//6
                return AjaxResult.error("第 " + (i + 1) + " 行：水掺量(kg/m³)应为数字");
            }

            if (!isNumber(cement)) {//7
                return AjaxResult.error("第 " + (i + 1) + " 行：水泥掺量(kg/m³)应为数字");
            }


            if (isBlank(cementModel)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：水泥型号不能为空");
            }
            if (isBlank(cementCao)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：水泥CaO含量不能为空");
            }
            if (isBlank(cementSio2)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：水泥SiO2含量不能为空");
            }
            if (isBlank(cementAl2o3)) {//11
                return AjaxResult.error("第 " + (i + 1) + " 行：cementAl2o3不能为空");

            }

            if (!isNumber(cementStrengthGrade)) {//
                return AjaxResult.error("第 " + (i + 1) + " 行：28天抗压强度(MPa应为数字");
            }

            if (isBlank(cementCompressive)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：水泥强度等级不能为空");
            }


            if (!cementRegionName.matches(regionPattern)) {
                return AjaxResult.error("第 " + (i + 1) + " 行：水泥来源地区不正确，应为“浙江省”或“浙江省-杭州市”或“浙江省-杭州市-余杭区/余杭县”");
            }//14

            /*石头 5-10*/

            if (!isNumber(stone510)) {//15
                return AjaxResult.error("第 " + (i + 1) + " 行:石5-10mm掺量应为数字");
            }

            if (isBlank(model)) {//16
                return AjaxResult.error("第 " + (i + 1) + " 行：石5-10mm型号不能为空");
            }

            if (isBlank(stoneSpecification)) {//16
                return AjaxResult.error("第 " + (i + 1) + " 行：石5-10mm石子规格(mm)不能为空");
            }

            if (!isNumber(stackingDensity)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:石头5-10堆积密度应为数字");
            }
            if (!isNumber(compactDensity)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:石头5-10堆紧密密度应为数字");
            }
            if (!isNumber(bulkdensity)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:石头5-10表观密度应为数字");
            }

            if (!regionNamestone510.matches(regionPattern)) {
                return AjaxResult.error("第 " + (i + 1) + " 行： 石头5-10来源地区不正确，应为“浙江省”或“浙江省-杭州市”或“浙江省-杭州市-余杭区/余杭县”");
            }//21



            /*5-25*/

            if (!isNumber(stone525)) {//15
                return AjaxResult.error("第 " + (i + 1) + " 行:石头5-25掺量应为数字");
            }

            if (isBlank(model525)) {//16
                return AjaxResult.error("第 " + (i + 1) + " 行：石头5-25型号不能为空");
            }

            if (isBlank(stoneSpecification525)) {//16
                return AjaxResult.error("第 " + (i + 1) + " 行：石头5-25石子规格(mm)不能为空");
            }

            if (!isNumber(stackingDensity525)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:石头5-25堆积密度应为数字");
            }
            if (!isNumber(compactDensity525)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:石头5-25堆紧密密度应为数字");
            }
            if (!isNumber(bulkdensity525)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:石头5-25表观密度应为数字");
            }

            if (!regionNamestone525.matches(regionPattern)) {
                return AjaxResult.error("第 " + (i + 1) + " 行： 石头5-25来源地区不正确，应为“浙江省”或“浙江省-杭州市”或“浙江省-杭州市-余杭区/余杭县”");

            }

            /*-------------石头20-40mm---------*/

            if (!isNumber(stone2040)) {//15
                return AjaxResult.error("第 " + (i + 1) + " 行:石头20-40mm掺量应为数字");
            }

            if (isBlank(model2040)) {//16
                return AjaxResult.error("第 " + (i + 1) + " 行：石头20-40mm型号不能为空");
            }

            if (isBlank(stoneSpecification2040)) {//16
                return AjaxResult.error("第 " + (i + 1) + " 行：石头20-40mm石子规格(mm)不能为空");
            }

            if (!isNumber(stackingDensity2040)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:石头20-40mm堆积密度应为数字");
            }
            if (!isNumber(compactDensity2040)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:石头20-40mm堆紧密密度应为数字");
            }
            if (!isNumber(bulkdensity2040)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:石头20-40mm表观密度应为数字");
            }

            if (!regionNamestone2040.matches(regionPattern)) {
                return AjaxResult.error("第 " + (i + 1) + " 行： 石头20-40mm来源地区不正确，应为“浙江省”或“浙江省-杭州市”或“浙江省-杭州市-余杭区/余杭县”");

            }
            /* 石头 10-20*/

            if (!isNumber(stone1020)) {//15
                return AjaxResult.error("第 " + (i + 1) + " 行:石头10-20mm掺量应为数字");
            }

            if (isBlank(model1020)) {//16
                return AjaxResult.error("第 " + (i + 1) + " 行：石头10-20mm型号不能为空");
            }

            if (isBlank(stoneSpecification1020)) {//16
                return AjaxResult.error("第 " + (i + 1) + " 行：石头10-20mm石子规格(mm)不能为空");
            }

            if (!isNumber(stackingDensity1020)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:石头10-20mm堆积密度应为数字");
            }
            if (!isNumber(compactDensity1020)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:石头10-20mm堆紧密密度应为数字");
            }
            if (!isNumber(bulkdensity1020)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:石头10-20mm表观密度应为数字");
            }

            if (!regionNamestone1020.matches(regionPattern)) {
                return AjaxResult.error("第 " + (i + 1) + " 行： 石头10-20mm来源地区不正确，应为“浙江省”或“浙江省-杭州市”或“浙江省-杭州市-余杭区/余杭县”");

            }

            /*石头10-30*/

            if (!isNumber(stone1030)) {//15
                return AjaxResult.error("第 " + (i + 1) + " 行:石头10-30mm掺量应为数字");
            }

            if (isBlank(model1030)) {//16
                return AjaxResult.error("第 " + (i + 1) + " 行：石头10-30mm型号不能为空");
            }

            if (isBlank(stoneSpecification1030)) {//16
                return AjaxResult.error("第 " + (i + 1) + " 行：石头10-30mm石子规格(mm)不能为空");
            }

            if (!isNumber(stackingDensity1030)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:石头10-30mm堆积密度应为数字");
            }
            if (!isNumber(compactDensity1030)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:石头10-30mm堆紧密密度应为数字");
            }
            if (!isNumber(bulkdensity1030)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:石头10-30mm表观密度应为数字");
            }

            if (!regionNamestone1030.matches(regionPattern)) {
                return AjaxResult.error("第 " + (i + 1) + " 行： 石头10-30mm来源地区不正确，应为“浙江省”或“浙江省-杭州市”或“浙江省-杭州市-余杭区/余杭县”");

            }


            /*石头 0-10*/

            if (!isNumber(stone010)) {//15
                return AjaxResult.error("第 " + (i + 1) + " 行:石头0-10mm掺量应为数字");
            }

            if (isBlank(model010)) {//16
                return AjaxResult.error("第 " + (i + 1) + " 行：石头0-10mm型号不能为空");
            }

            if (isBlank(stoneSpecification010)) {//16
                return AjaxResult.error("第 " + (i + 1) + " 行：石头0-10mm石子规格(mm)不能为空");
            }

            if (!isNumber(stackingDensity010)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:石头0-10mm堆积密度应为数字");
            }
            if (!isNumber(compactDensity010)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:石头0-10mm堆紧密密度应为数字");
            }
            if (!isNumber(bulkdensity010)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:石头0-10mm表观密度应为数字");
            }

            if (!regionNamestone010.matches(regionPattern)) {
                return AjaxResult.error("第 " + (i + 1) + " 行： 石头0-10mm来源地区不正确，应为“浙江省”或“浙江省-杭州市”或“浙江省-杭州市-余杭区/余杭县”");

            }
            /*石头20-31.5mm*/

            if (!isNumber(stone20315)) {//15
                return AjaxResult.error("第 " + (i + 1) + " 行:石头20-31.5mm掺量应为数字");
            }

            if (isBlank(model20315)) {//16
                return AjaxResult.error("第 " + (i + 1) + " 行：石头20-31.5mm型号不能为空");
            }

            if (isBlank(stoneSpecification20315)) {//16
                return AjaxResult.error("第 " + (i + 1) + " 行：石头20-31.5mm石子规格(mm)不能为空");
            }

            if (!isNumber(stackingDensity20315)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:石头20-31.5mm堆积密度应为数字");
            }
            if (!isNumber(compactDensity20315)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:石头20-31.5mm堆紧密密度应为数字");
            }
            if (!isNumber(bulkdensity20315)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:石头20-31.5mm表观密度应为数字");
            }

            if (!regionNamestone20315.matches(regionPattern)) {
                return AjaxResult.error("第 " + (i + 1) + " 行： 石头20-31.5mm来源地区不正确，应为“浙江省”或“浙江省-杭州市”或“浙江省-杭州市-余杭区/余杭县”");

            }

            /*河砂粗3.1-3.7mm*/
            if (!isNumber(sand3137)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:河砂粗3.1-3.7mm掺量应为数字");
            }

            if (isBlank(model3137)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：河砂粗3.1-3.7mm型号不能为空");
            }

            if (!isNumber(fineness3137)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:河砂粗3.1-3.7mm细度应为数字");
            }

            if (!isNumber(bulkDensity3137)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:河砂粗3.1-3.7mm堆积密度应为数字");
            }
            if (!isNumber(compactDensity3137)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:河砂粗3.1-3.7mm紧密密度为数字");
            }
            if (!isNumber(apparentDensity3137)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:河砂粗3.1-3.7mm表观密度应为数字");
            }

            if (isBlank(particleSizeDistribution3137)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：河砂粗3.1-3.7mm粒径分布不能为空");
            }

            if (!regionSandName3137.matches(regionPattern)) {
                return AjaxResult.error("第 " + (i + 1) + " 行： 河砂粗3.1-3.7mm来源地区不正确，应为“浙江省”或“浙江省-杭州市”或“浙江省-杭州市-余杭区/余杭县”");

            }

            /*河砂粗砂23-30*/
            if (!isNumber(sand2330)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:河砂粗23-30mm掺量应为数字");
            }

            if (isBlank(model2330)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：河砂粗23-30mm型号不能为空");
            }

            if (!isNumber(fineness2330)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:河砂粗23-30mm细度应为数字");
            }

            if (!isNumber(bulkDensity2330)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:河砂粗23-30mm堆积密度应为数字");
            }
            if (!isNumber(compactDensity2330)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:河砂粗23-30mm紧密密度为数字");
            }
            if (!isNumber(apparentDensity2330)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:河砂粗23-30mm表观密度应为数字");
            }

            if (isBlank(particleSizeDistribution2330)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：河砂粗23-30mm粒径分布不能为空");
            }

            if (!regionSandName2330.matches(regionPattern)) {
                return AjaxResult.error("第 " + (i + 1) + " 行： 河砂粗23-30mm来源地区不正确，应为“浙江省”或“浙江省-杭州市”或“浙江省-杭州市-余杭区/余杭县”");

            }

            /*河砂细16-22mm*/
            if (!isNumber(sand1622)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:河砂细16-22mm掺量应为数字");
            }

            if (isBlank(model1622)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：河砂细16-22mm型号不能为空");
            }

            if (!isNumber(fineness1622)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:河砂细16-22mm细度应为数字");
            }

            if (!isNumber(bulkDensity1622)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:河砂细16-22mm堆积密度应为数字");
            }
            if (!isNumber(compactDensity1622)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:河砂细16-22mm紧密密度为数字");
            }
            if (!isNumber(apparentDensity1622)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:河砂细16-22mm表观密度应为数字");
            }

            if (isBlank(particleSizeDistribution1622)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：河砂细16-22mm粒径分布不能为空");
            }

            if (!regionSandName1622.matches(regionPattern)) {
                return AjaxResult.error("第 " + (i + 1) + " 行： 河砂细16-22mm来源地区不正确，应为“浙江省”或“浙江省-杭州市”或“浙江省-杭州市-余杭区/余杭县”");

            }
            /*机制砂中23-30Bmm*/

            if (!isNumber(sand2330B)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:机制砂中23-30mm掺量应为数字");
            }

            if (isBlank(model2330B)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：机制砂中23-30mm型号不能为空");
            }

            if (!isNumber(fineness2330B)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:机制砂中23-30mm细度应为数字");
            }

            if (!isNumber(bulkDensity2330B)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:机制砂中23-30mm堆积密度应为数字");
            }
            if (!isNumber(compactDensity2330B)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:机制砂中23-30mm紧密密度为数字");
            }
            if (!isNumber(apparentDensity2330B)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:机制砂中23-30mm表观密度应为数字");
            }

            if (isBlank(particleSizeDistribution2330B)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：机制砂中23-30mm粒径分布不能为空");
            }

            if (!regionSandName2330B.matches(regionPattern)) {
                return AjaxResult.error("第 " + (i + 1) + " 行： 机制砂中23-30mm来源地区不正确，应为“浙江省”或“浙江省-杭州市”或“浙江省-杭州市-余杭区/余杭县”");

            }
            /*机制砂粗31-37Bmm*/

            if (!isNumber(sand3137B)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:机制砂粗31-37mm掺量应为数字");
            }

            if (isBlank(model3137B)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：机制砂粗31-37mm型号不能为空");
            }

            if (!isNumber(fineness3137B)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:机制砂粗31-37mm细度应为数字");
            }

            if (!isNumber(bulkDensity3137B)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:机制砂粗31-37mm堆积密度应为数字");
            }
            if (!isNumber(compactDensity3137B)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:机制砂粗31-37mm紧密密度为数字");
            }
            if (!isNumber(apparentDensity3137B)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:机制砂粗31-37mm表观密度应为数字");
            }

            if (isBlank(particleSizeDistribution3137B)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：机制砂粗31-37mm粒径分布不能为空");
            }

            if (!regionSandName3137B.matches(regionPattern)) {
                return AjaxResult.error("第 " + (i + 1) + " 行： 机制砂粗31-37mm来源地区不正确，应为“浙江省”或“浙江省-杭州市”或“浙江省-杭州市-余杭区/余杭县”");

            }
            /*机制砂细16-22Bmm*/
            if (!isNumber(sand1622B)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:机制砂细16-22mm掺量应为数字");
            }

            if (isBlank(model1622B)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：机制砂细16-22mm型号不能为空");
            }

            if (!isNumber(fineness1622B)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:机制砂细16-22mm细度应为数字");
            }

            if (!isNumber(bulkDensity1622B)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:机制砂细16-22mm堆积密度应为数字");
            }
            if (!isNumber(compactDensity1622B)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:机制砂细16-22mm紧密密度为数字");
            }
            if (!isNumber(apparentDensity1622B)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:机制砂细16-22mm表观密度应为数字");
            }

            if (isBlank(particleSizeDistribution1622B)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：机制砂细16-22mm粒径分布不能为空");
            }

            if (!regionSandName1622B.matches(regionPattern)) {
                return AjaxResult.error("第 " + (i + 1) + " 行： 机制砂细16-22mm来源地区不正确，应为“浙江省”或“浙江省-杭州市”或“浙江省-杭州市-余杭区/余杭县”");

            }

            /*机制砂0-4.75mm*/


            if (!isNumber(sand0475)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:机制砂0-4.75mm掺量应为数字");
            }

            if (isBlank(model0475)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：机制砂0-4.75mm型号不能为空");
            }

            if (!isNumber(fineness0475)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:机制砂0-4.75mm细度应为数字");
            }

            if (!isNumber(bulkDensity0475)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:机制砂0-4.75mm堆积密度应为数字");
            }
            if (!isNumber(compactDensity0475)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:机制砂0-4.75mm紧密密度为数字");
            }
            if (!isNumber(apparentDensity0475)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:机制砂0-4.75mm表观密度应为数字");
            }

            if (isBlank(particleSizeDistribution0475)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：机制砂0-4.75mm粒径分布不能为空");
            }

            if (!regionSandName0475.matches(regionPattern)) {
                return AjaxResult.error("第 " + (i + 1) + " 行： 机制砂0-4.75mm来源地区不正确，应为“浙江省”或“浙江省-杭州市”或“浙江省-杭州市-余杭区/余杭县”");

            }


            /*机制砂0-9mm*/


            if (!isNumber(sand09)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:机制砂0-9mm掺量应为数字");
            }

            if (isBlank(model09)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：机制砂0-9mm型号不能为空");
            }

            if (!isNumber(fineness09)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:机制砂0-9mm细度应为数字");
            }

            if (!isNumber(bulkDensity09)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:机制砂0-9mm堆积密度应为数字");
            }
            if (!isNumber(compactDensity09)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:机制砂0-9mm紧密密度为数字");
            }
            if (!isNumber(apparentDensity09)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:机制砂0-9mm表观密度应为数字");
            }

            if (isBlank(particleSizeDistribution09)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：机制砂0-9mm粒径分布不能为空");
            }

            if (!regionSandName09.matches(regionPattern)) {
                return AjaxResult.error("第 " + (i + 1) + " 行： 机制砂0-9mm来源地区不正确，应为“浙江省”或“浙江省-杭州市”或“浙江省-杭州市-余杭区/余杭县”");

            }

            /*石粉*/
            if (!isNumber(otherAdmixtures)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:石粉掺量应为数字");
            }

            if (isBlank(modelotherAdmixtures)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：石粉型号不能为空");
            }

            if (!isNumber(finenessotherAdmixtures)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:石粉细度应为数字");
            }

            if (!isNumber(moistureContentotherAdmixtures)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:石粉含水量(%)应为数字");
            }
            if (!isNumber(activityIndex28dOtherAdmixtures)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:石粉28天活性指数(%)应为数字");
            }

            if (!regionNameOtherAdmixtures.matches(regionPattern)) {
                return AjaxResult.error("第 " + (i + 1) + " 行： 石粉来源地区不正确，应为“浙江省”或“浙江省-杭州市”或“浙江省-杭州市-余杭区/余杭县”");

            }
            /*矿粉*/
            if (!isNumber(mineralPowder)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:矿粉掺量应为数字");
            }

            if (isBlank(mineralPowdermodel)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：矿粉型号不能为空");
            }

            if (isBlank(mineralPowderSlagGrade)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：矿粉等级不能为空");
            }

            if (!isNumber(mineralPowderFineness)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:石粉细度应为数字");
            }

            if (!isNumber(mineralPowdermoistureContent)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:矿粉含水量(%)应为数字");
            }
            if (!isNumber(mineralPowderactivityIndex28d)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:矿粉28天活性指数(%)应为数字");
            }

            if (!mineralPowderregionName.matches(regionPattern)) {
                return AjaxResult.error("第 " + (i + 1) + " 行： 矿粉来源地区不正确，应为“浙江省”或“浙江省-杭州市”或“浙江省-杭州市-余杭区/余杭县”");

            }
            /*粉煤灰*/
            if (!isNumber(sysFlyash)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:粉煤灰掺量应为数字");
            }

            if (isBlank(flyashModel)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：粉煤灰型号不能为空");
            }
            if (isBlank(flyashFactoryGrade)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：粉煤灰出厂等级");
            }

            if (!isNumber(flyashFineness)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:粉煤灰细度应为数字");
            }

            if (!isNumber(flyashMoistureContent)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:粉煤灰含水量(%)应为数字");
            }
            if (!isNumber(flyashActivityIndex28d)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:粉煤灰28天活性指数(%)应为数字");
            }

            if (!flyashRegionName.matches(regionPattern)) {
                return AjaxResult.error("第 " + (i + 1) + " 行： 粉煤灰来源地区不正确，应为“浙江省”或“浙江省-杭州市”或“浙江省-杭州市-余杭区/余杭县”");

            }

            /*减水剂*/
            if (!isNumber(waterReducer)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:减水剂掺量应为数字");
            }

            if (isBlank(waterReducerModel)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：减水剂型号不能为空");
            }


            if (!isNumber(waterReducersolidContent)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:减水剂含固量应为数字");
            }

            if (!isNumber(waterReducercementPasteFlow)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:减水剂水泥净浆流动度(mm)应为数字");
            }
            if (!isNumber(waterReducerreducingRate)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:减水剂减水率应为数字");
            }



            if (isBlank(waterReducerRegionName)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：减水剂商家不能为空");
            }
            /*增效剂*/
            if (!isNumber(efficiencyAgent)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:增效剂掺量应为数字");
            }

            if (isBlank(efficiencyAgentModel)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：增效剂型号不能为空");
            }

//            if (!efficiencyAgentName.matches(regionPattern)) {
//                return AjaxResult.error("第 " + (i + 1) + " 行： 增效剂来源来源地区不正确，应为“浙江省”或“浙江省-杭州市”或“浙江省-杭州市-余杭区/余杭县”");
//
//            }
            if (isBlank(efficiencyAgentName)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：增效剂商家不能为空");
            }

            /*增效剂*/
            if (!isNumber(swellingagentAgent)) {
                return AjaxResult.error("第 " + (i + 1) + " 行:膨胀剂掺量应为数字");
            }

            if (isBlank(swellingagentModel)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：膨胀剂型号不能为空");
            }
//
//            if (!swellingagentName.matches(regionPattern)) {
//                return AjaxResult.error("第 " + (i + 1) + " 行： 膨胀剂来源来源地区不正确，应为“浙江省”或“浙江省-杭州市”或“浙江省-杭州市-余杭区/余杭县”");
//
//            }


            if (isBlank(swellingagentName)) {//12
                return AjaxResult.error("第 " + (i + 1) + " 行：膨胀剂商家不能为空");
            }


            Region matched = matchOrInsertRegion(region, fullNameMap);
            if (matched == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(0, String.valueOf(matched.getId()));

            Region matched14 = matchOrInsertRegion(cementRegionName, fullNameMap);
            if (matched14 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(14, String.valueOf(matched14.getId()));

            Region matchedregionNamestone510 = matchOrInsertRegion(regionNamestone510, fullNameMap);
            if (matchedregionNamestone510 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(21, String.valueOf(matchedregionNamestone510.getId()));

            Region matchedregionNamestone525 = matchOrInsertRegion(regionNamestone525, fullNameMap);
            if (matchedregionNamestone525 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(28, String.valueOf(matchedregionNamestone525.getId()));


            Region matchedregionNamestone2040 = matchOrInsertRegion(regionNamestone2040, fullNameMap);
            if (matchedregionNamestone2040 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(35, String.valueOf(matchedregionNamestone2040.getId()));


            Region matchedregionNamestone1020 = matchOrInsertRegion(regionNamestone1020, fullNameMap);
            if (matchedregionNamestone1020 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(42, String.valueOf(matchedregionNamestone1020.getId()));


            Region matchedregionNamestone1030 = matchOrInsertRegion(regionNamestone1030, fullNameMap);
            if (matchedregionNamestone1020 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(49, String.valueOf(matchedregionNamestone1030.getId()));

            Region matchedregionNamestone010 = matchOrInsertRegion(regionNamestone010, fullNameMap);
            if (matchedregionNamestone010 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(56, String.valueOf(matchedregionNamestone010.getId()));


            Region matchedregionNamestone20315 = matchOrInsertRegion(regionNamestone20315, fullNameMap);
            if (matchedregionNamestone20315 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(63, String.valueOf(matchedregionNamestone20315.getId()));


            Region SandName3137 = matchOrInsertRegion(regionSandName3137, fullNameMap);
            if (SandName3137 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(71, String.valueOf(SandName3137.getId()));


            Region SandName2330 = matchOrInsertRegion(regionSandName2330, fullNameMap);
            if (SandName2330 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(79, String.valueOf(SandName2330.getId()));


            Region SandName1622 = matchOrInsertRegion(regionSandName1622, fullNameMap);
            if (SandName1622 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(87, String.valueOf(SandName1622.getId()));

            Region SandName2330B = matchOrInsertRegion(regionSandName2330B, fullNameMap);
            if (SandName2330B == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(95, String.valueOf(SandName2330B.getId()));


            Region SandName3137B = matchOrInsertRegion(regionSandName3137B, fullNameMap);
            if (SandName3137B == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(103, String.valueOf(SandName3137B.getId()));

            Region SandName1622B = matchOrInsertRegion(regionSandName1622B, fullNameMap);
            if (SandName1622B == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(111, String.valueOf(SandName1622B.getId()));


            Region SandName0475 = matchOrInsertRegion(regionSandName0475, fullNameMap);
            if (SandName0475 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(119, String.valueOf(SandName0475.getId()));


            Region SandName09 = matchOrInsertRegion(regionSandName09, fullNameMap);
            if (SandName09 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(127, String.valueOf(SandName09.getId()));


            Region SandName133 = matchOrInsertRegion(regionNameOtherAdmixtures, fullNameMap);
            if (SandName133 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(133, String.valueOf(SandName133.getId()));

            Region SandName140 = matchOrInsertRegion(mineralPowderregionName, fullNameMap);
            if (SandName140 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(140, String.valueOf(SandName140.getId()));


            Region SandName147 = matchOrInsertRegion(flyashRegionName, fullNameMap);
            if (SandName147 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(147, String.valueOf(SandName147.getId()));


        }
        return AjaxResult.success("水泥数据校验通过，地区已处理");
    }








    /*----------------------------------------以下是审核接口代码---------------------------------------------*/

    /**
     * 管理员审核
     *
     * @param auditRequestDTO
     */
//    @Override
//    public AjaxResult updateAudit(AuditRequestDTO auditRequestDTO) {
//        String filePath = auditRequestDTO.getFilePath();
//        Integer tableName = auditRequestDTO.getTableName();
//        String id = auditRequestDTO.getId();
//        Integer status = auditRequestDTO.getStatus();
//        //根据id修改status的状态值
//
//        //审核通过
//        if (status == 1) {
//            //根据tableName字段确定表的名称 解析json插入数据库 插入成功之后修改状态为  1
//            String targetTable;
//            switch (tableName) {
//                case 1:
//                    targetTable = "sys_cement";
//                    break;
//                case 2:
//                    targetTable = "sys_sand";
//                    break;
//                case 3:
//                    targetTable = "sys_stone";
//                    break;
//                case 4:
//                    targetTable = "sys_flyash";
//                    saveSysFlyash(filePath, id, status);
//
//                case 5:
//                    targetTable = "sys_water_reducer";
//                    break;
//                case 6:
//                    targetTable = "sys_efficiency_agent";
//                    break;
//                default:
//                    throw new IllegalArgumentException("无效的表名编号");
//            }
//
//            // 根据id更新stusus的值
//
//            //审核不过
//        } else if (status == 2) {
//            //返回信息不做其他处理
//
//        }
//
//
//        //参数校验
//        // 确定目标表
//        //如果status==1则审核通过插入数据库
//
//
//        // 其他表处理逻辑可以在这里扩展
//
//
//        return null;
//    }
//
//    private AjaxResult saveSysFlyash(String filePath, String id, Integer status) {
//        ObjectMapper objectMapper = new ObjectMapper();
//        List<List<String>> data;
//
//        // 解析 JSON 文件
//        try {
//            File jsonFile = new File(filePath);
//            if (!jsonFile.exists()) {
//                return AjaxResult.error("文件不存在: " + filePath);
//            }
//
//            data = objectMapper.readValue(jsonFile, new com.fasterxml.jackson.core.type.TypeReference<List<List<String>>>() {});
//        } catch (IOException e) {
//            e.printStackTrace();
//            return AjaxResult.error("JSON 文件解析失败: " + e.getMessage());
//        }
//
//        // 遍历并处理每条记录
//        for (List<String> record : data) {
//            if (record.size() != 3) {
//                continue; // 跳过格式不正确的数据
//            }
//
//            String grade = record.get(0);
//            String fineness = record.get(1);
//            String regionName = record.get(2);
//
//            try {
//                // 查询 sys_region 表，检查 region_name 是否存在
//                SysRegion region = sysRegionMapper.selectOne(
//                        new QueryWrapper<SysRegion>().eq("region_name", regionName));
//
//                // 如果 region_name 不存在，插入一条新记录并获取 region_id
//                Integer regionId;
//                if (region == null) {
//                    region = new SysRegion();
//                    region.setRegionName(regionName);
//                    region.setCreateTime(Timestamp.valueOf(LocalDateTime.now()));
//                    sysRegionMapper.insert(region);
//
//                    // 获取插入记录的 region_id
//                    regionId = region.getRegionId(); // 需要在实体类中添加 `regionId` 的获取逻辑
//                } else {
//                    regionId = region.getRegionId();
//                }
//
//                // 插入粉煤灰数据
//                SysFlyash flyash = new SysFlyash();
//                flyash.setGrade(grade);
//                flyash.setFineness(new BigDecimal(fineness).doubleValue()); // 转换为 Double 类型
//                flyash.setRegionName(regionId); // 存储 region_id
//                flyash.setCreateTime(Timestamp.valueOf(LocalDateTime.now()));
//
//                int insert = sysFlyashMapper.insert(flyash);
//                if (insert > 0) {
//                    // 更新审核状态
//                    updateAuditStatus(id, status);
//                    return AjaxResult.success("审核通过并插入粉煤灰数据成功");
//                } else {
//                    System.out.println("粉煤灰数据插入失败！");
//                }
//            } catch (Exception e) {
//                e.printStackTrace();
//                System.err.println("插入数据失败: " + record);
//            }
//        }
//
//        return AjaxResult.error("没有有效数据被插入");
//    }
//
//    private void updateAuditStatus(String id, Integer status) {
//        // 创建更新对象
//        SysFileAudit fileAudit = new SysFileAudit();
//        fileAudit.setStatus(status);
//
//        // 构造条件
//        LambdaQueryWrapper<SysFileAudit> wrapper = new LambdaQueryWrapper<>();
//        wrapper.eq(SysFileAudit::getId, id);
//
//        // 执行更新操作
//        int updatedRows = sysFileAuditMapper.update(fileAudit, wrapper);
//        if (updatedRows > 0) {
//            System.out.println("审核状态更新成功, ID: " + id + ", 新状态: " + status);
//        } else {
//            System.out.println("审核状态更新失败, ID: " + id);
//        }
//    }
//


//    private AjaxResult saveSysFlyash(String filePath, String id, Integer status) {
//        ObjectMapper objectMapper = new ObjectMapper();
//        List<List<String>> data;
//        try {
//            File jsonFile = new File(filePath);
//            if (!jsonFile.exists()) {
//                throw new IOException("文件不存在: " + filePath);
//            }
//
//            // 解析 JSON 数据
//            data = objectMapper.readValue(jsonFile, new com.fasterxml.jackson.core.type.TypeReference<List<List<String>>>() {
//            });
//            System.out.println("解析数据: " + data);
//        } catch (IOException e) {
//            e.printStackTrace();
//            throw new RuntimeException("JSON 解析失败: " + e.getMessage());
//        }
//
//        // 逐条处理解析的数据
//        for (List<String> record : data) {
//            if (record.size() != 3) {
//                continue; // 数据格式不正确，跳过
//            }
//
//            String grade = record.get(0);
//            String fineness = record.get(1);
//            String regionName = record.get(2);
//
//            try {
//                // 查询 sys_region 表，检查 region_name 是否存在
//                SysRegion region = sysRegionMapper.selectOne(
//                        new QueryWrapper<SysRegion>()
//                                .eq("region_name", regionName)
//
//                );
//
//
//                    // 如果 region_name 不存在，插入一条新记录
//                    region = new SysRegion();
//                    region.setRegionName(regionName);
//                    region.setCreateTime(Timestamp.valueOf(LocalDateTime.now())); // 转换为 Date
//                    sysRegionMapper.insert(region);
//
//
//                // 插入粉煤灰数据
//                SysFlyash flyash = new SysFlyash();
//                flyash.setGrade(grade);
//                // 将 fineness 转换为 Double 类型
//                flyash.setFineness(new BigDecimal(fineness).doubleValue()); // 转换为 Double 类型
//                // 将 regionId 转换为 String 类型
//                // flyash.setRegionName(String.valueOf(regionId)); // 转换为 String 类型
//                flyash.setCreateTime(Timestamp.valueOf(LocalDateTime.now()));
//                int insert = sysFlyashMapper.insert(flyash);
//                if (insert > 0) {
//                    SysFileAudit fileAudit = new SysFileAudit();
//                    fileAudit.setStatus(status);
//                    LambdaQueryWrapper<SysFileAudit> wrapper = new LambdaQueryWrapper<>();
//                    wrapper.eq(SysFileAudit::getId, id);
//                    sysFileAuditMapper.update(fileAudit, wrapper);
//                    return AjaxResult.success("审核通过");
//
//                } else {
//                    System.out.println("插入失败！");
//                }
//
//            } catch (Exception e) {
//                e.printStackTrace();
//                System.err.println("插入数据失败: " + record);
//            }
//        }
//        return null;
//    }


    /**
     * 14 插入坍落度
     *
     * @param filePath
     * @param id
     * @param status
     * @return
     */
    @Transactional
    public AjaxResult saveSysSlumpPerformance(String filePath, String id, Integer status) {
        ObjectMapper objectMapper = new ObjectMapper();
        List<List<String>> data;
        try {
            // 检查文件是否存在
            File jsonFile = new File(filePath);
            if (!jsonFile.exists()) {
                return AjaxResult.error("文件不存在: " + filePath);
            }

            // 解析 JSON 文件为二维数组（每一行是一条水泥记录）
            data = objectMapper.readValue(jsonFile, new com.fasterxml.jackson.core.type.TypeReference<List<List<String>>>() {
            });
        } catch (IOException e) {
            e.printStackTrace();
            return AjaxResult.error("JSON 文件解析失败: " + e.getMessage());
        }


        int successfulInserts = 0;


        // 获取水泥数据并存储在一个集合中
        LambdaQueryWrapper<SysCement> wrapper = new LambdaQueryWrapper<>();
        List<SysCement> list = sysCementService.list(wrapper);
        Map<String, SysCement> sysCementMap = new HashMap<>();

        for (SysCement sysCement : list) {
            String key = sysCement.getModel() + "-" + sysCement.getRegionName() + "-" + sysCement.getStrengthGrade() +
                    "-" + sysCement.getCaoContent() + "-" + sysCement.getSio2Content() + "-" + sysCement.getAl2o3Content() + "-" + sysCement.getCompressiveStrength28d();
            sysCementMap.put(key, sysCement);  // 使用一个唯一的组合键作为 map 的 key
        }


        // 获取所有已存在的石头记录并存储在一个集合中
        LambdaQueryWrapper<SysStone> wrapperStone = new LambdaQueryWrapper<>();
        List<SysStone> listStone = sysStoneService.list(wrapperStone);
        Map<String, SysStone> sysStonMap = new HashMap<>();
        System.out.println("sysCementMap" + sysStonMap);
        for (SysStone sysCement : listStone) {
            String keyStone = sysCement.getModel() + "-" + sysCement.getStoneSpecification() +
                    "-" + sysCement.getStackingDensity() + "-" + sysCement.getCompactDensity() +
                    "-" + sysCement.getBulkDensity() + "-" + sysCement.getRegionName();

            sysStonMap.put(keyStone, sysCement);
        }


        // 获取所有已存在的水泥记录并存储在一个集合中
        LambdaQueryWrapper<SysFlyash> wrapperFlyash = new LambdaQueryWrapper<>();
        List<SysFlyash> listFlyash = sysFlyashService.list(wrapperFlyash);
        Map<String, SysFlyash> flyashMap = new HashMap<>();

        for (SysFlyash sysCement : listFlyash) {
            String keyFlyash = sysCement.getGrade() + "-" + sysCement.getFactoryGrade() + "-" + sysCement.getFineness() +
                    "-" + sysCement.getMoistureContent() + "-" + sysCement.getActivityIndex28d() + "-" + sysCement.getRegionName();
            flyashMap.put(keyFlyash, sysCement);  // 使用一个唯一的组合键作为 map 的 key
        }


        // 获取所有已存在的砂记录并存储在一个集合中
        LambdaQueryWrapper<SysSand> wrapperSand = new LambdaQueryWrapper<>();
        List<SysSand> listSand = sysSandService.list(wrapperSand);
        // 使用一个唯一的组合键作为 Map 的 key
        Map<String, SysSand> sysSandMap = new HashMap<>();
        for (SysSand sysCement : listSand) {
            String key = sysCement.getType() + "-" + sysCement.getFineness() + "-" + sysCement.getBulkDensity() + "-"
                    + sysCement.getCompactDensity() + "-" + sysCement.getApparentDensity() + "-" + sysCement.getParticleSizeDistribution()
                    + "-" + sysCement.getRegionName();
            sysSandMap.put(key, sysCement);  // 使用唯一的组合键作为 map 的 key
        }


        // 获取所有已存在的石粉记录并存储在一个集合中
        LambdaQueryWrapper<SysOtherAdmixtures> wrapperOtherAdmixtures = new LambdaQueryWrapper<>();
        List<SysOtherAdmixtures> listOtherAdmixtures = sysOtherAdmixturesService.list(wrapperOtherAdmixtures);
        Map<String, SysOtherAdmixtures> sysOtherAdmixturesMap = new HashMap<>();
        System.out.println("sysCementMap" + sysCementMap);
        for (SysOtherAdmixtures sysCement : listOtherAdmixtures) {
            String key = sysCement.getModel() + "-" + sysCement.getFineness() +
                    "-" + sysCement.getMoistureContent() + "-" + sysCement.getActivityIndex28d() + "-" + sysCement.getRegionName();
            sysOtherAdmixturesMap.put(key, sysCement);  // 使用一个唯一的组合键作为 map 的 key
        }


        /*矿粉*/
        LambdaQueryWrapper<SysMineralPowder> wrapperMineralPowder = new LambdaQueryWrapper<>();
        List<SysMineralPowder> listMineralPowder = sysMineralPowderService.list(wrapperMineralPowder);
        Map<String, SysMineralPowder> MineralPowderMap = new HashMap<>();

        for (SysMineralPowder sysCement : listMineralPowder) {
            String key = sysCement.getModel() + "-" + sysCement.getSlagGrade() + "-" + sysCement.getFineness() +
                    "-" + sysCement.getMoistureContent() + "-" + sysCement.getActivityIndex28d() + "-" + sysCement.getRegionName();
            MineralPowderMap.put(key, sysCement);  // 使用一个唯一的组合键作为 map 的 key
        }


        //减水剂
        LambdaQueryWrapper<SysWaterReducer> wrapperWaterReducer = new LambdaQueryWrapper<>();
        List<SysWaterReducer> listWaterReducer = sysWaterReducerService.list(wrapperWaterReducer);
        Map<String, SysWaterReducer> sysWaterReducerMap = new HashMap<>();
        System.out.println("list" + list);
        for (SysWaterReducer sysCement : listWaterReducer) {
            String keyWaterReducer = sysCement.getModel() + "-" + sysCement.getSolidContent() + "-" + sysCement.getCementPasteFlow() + "-" + sysCement.getReducingRate() + "-" + sysCement.getSourceName();

            sysWaterReducerMap.put(keyWaterReducer, sysCement);  // 使用一个唯一的组合键作为 map 的 key
        }

       // System.out.println("减水剂数据库字段" + sysWaterReducerMap);

        /*增效剂*/
        LambdaQueryWrapper<SysEfficiencyAgent> wrapperEfficiencyAgent = new LambdaQueryWrapper<>();
        List<SysEfficiencyAgent> listEfficiencyAgent = sysEfficiencyAgentService.list(wrapperEfficiencyAgent);
        Map<String, SysEfficiencyAgent> efficiencyAgentMap = new HashMap<>();
        System.out.println("list" + listEfficiencyAgent);
        for (SysEfficiencyAgent sysCement : listEfficiencyAgent) {
            String key = sysCement.getModel() + "-" + sysCement.getSourceName();
            efficiencyAgentMap.put(key, sysCement);  // 使用一个唯一的组合键作为 map 的 key
        }


        /*膨胀剂*/
        // 获取所有已存在的水泥记录并存储在一个集合中
        LambdaQueryWrapper<SysSwellingagent> wrapperSwellingagent = new LambdaQueryWrapper<>();
        List<SysSwellingagent> listSysSwelling = sysSwellingagentService.list(wrapperSwellingagent);
        Map<String, SysSwellingagent> SysSwellingMap = new HashMap<>();
       // System.out.println("list" + listSysSwelling);
        for (SysSwellingagent sysCement : listSysSwelling) {
            String key = sysCement.getModel() + "-" + sysCement.getSourceName();
            SysSwellingMap.put(key, sysCement);  // 使用一个唯一的组合键作为 map 的 key
        }


        // 创建一个临时列表，用于存储要插入的数据
        //  List<SysMechanicalPerformance> batchInsertList = new ArrayList<>();
        List<SysSlump> batchInsertList = new ArrayList<>();

        // 遍历每条水泥数据
        for (List<String> record : data) {
//            if (record.size() != 15) {
//                System.err.println("无效数据格式: " + record);
//                continue;
//            }


            // 解析数据
            //String regiona = record.get(0);  // 地区
            int regiona = Integer.parseInt(record.get(0));//来源地区

            // String productionDate = record.get(1);  // //生产日期
            String productionDateStr = record.get(1);
            LocalDateTime productionDate = LocalDate.parse(productionDateStr, DateTimeFormatter.ofPattern("yyyy-MM-dd"))
                    .atStartOfDay();


            //String slump = record.get(2);
            BigDecimal slump = new BigDecimal(record.get(2));
            slump = slump.setScale(2, RoundingMode.HALF_UP);

            ;//强度等级
//            BigDecimal compressive3d = new BigDecimal(record.get(3));
//            ;//3天抗压强度(MPa)
//            BigDecimal compressive7d = new BigDecimal(record.get(4));  //7天抗压强度(MPa)
//            BigDecimal compressive28d = new BigDecimal(record.get(5));  //28天抗压强度(MPa)
            BigDecimal water = new BigDecimal(record.get(6));   //水掺量(kg/m³)

            BigDecimal cement = new BigDecimal(record.get(7));
            ;////水泥掺量(kg/m³)

            water = water.setScale(2, RoundingMode.HALF_UP);
            cement = cement.setScale(2, RoundingMode.HALF_UP);







            /*水泥*/
            // 解析数据
            String model = record.get(8);
            BigDecimal cao = new BigDecimal(record.get(9));
            BigDecimal sio2 = new BigDecimal(record.get(10));
            BigDecimal al2o3 = new BigDecimal(record.get(11));

//            BigDecimal compressive = new BigDecimal(record.get(12));
//            BigDecimal strength = new BigDecimal(record.get(13));
            BigDecimal strength = new BigDecimal(record.get(12));
            BigDecimal compressive = new BigDecimal(record.get(13));


            int region = Integer.parseInt(record.get(14));

            // 确保所有 BigDecimal 保留两位小数
            cao = cao.setScale(2, RoundingMode.HALF_UP);
            sio2 = sio2.setScale(2, RoundingMode.HALF_UP);
            al2o3 = al2o3.setScale(2, RoundingMode.HALF_UP);
            compressive = compressive.setScale(2, RoundingMode.HALF_UP);
            strength = strength.setScale(2, RoundingMode.HALF_UP);

            // 构造一个唯一的键
            String key = model + "-" + region + "-" + strength + "-" + cao + "-" + sio2 + "-" + al2o3 + "-" + compressive;

            Integer cementId;

            if (sysCementMap.containsKey(key)) {
                // 记录存在，直接拿id
//                cementId = sysCementMap.get(key).getId();
                cementId = sysCementMap.get(key).getCementId();  // 使用正确的字段名称
              //  System.out.println("找到已有水泥数据，id = " + cementId);
            } else {
                // 记录不存在，创建新的SysCement
                SysCement newCement = new SysCement();
                newCement.setId(IdUtils.generateRandomNumber());  // 生成id
                newCement.setModel(model);
                newCement.setRegionName(region); // 注意，regionName是字符串！
                newCement.setStrengthGrade(strength);
                newCement.setCaoContent(cao);
                newCement.setSio2Content(sio2);
                newCement.setAl2o3Content(al2o3);
                newCement.setCompressiveStrength28d(compressive);
                newCement.setCreateTime(Timestamp.valueOf(LocalDateTime.now()));

                sysCementService.save(newCement);
                sysCementMap.put(key, newCement); // 插入map缓存
                cementId = newCement.getCementId();
              //  System.out.println("新增水泥数据，id = " + cementId);
            }
//            // 替换第8列（索引8）为水泥id
//            record.set(8, String.valueOf(cementId));
//          // 删除索引9到14的元素（一定要从大到小删）
//            for (int i = 14; i >= 9; i--) {
//                record.remove(i);
//            }


            /*-------------------------------------------------------------------------------------*/
            // String stone510 = record.get(15);// 石头5-10掺量
            BigDecimal stone510 = new BigDecimal(record.get(15));// 石头5-10掺量
            stone510 = stone510.setScale(2, RoundingMode.HALF_UP);

            /*石头5-10*/
            // 解析数据并保证两位小数
            String modelstone510 = record.get(16); // 型号
            String stoneSpecification510 = record.get(17); // 石子规格
            BigDecimal stackingDensity510 = new BigDecimal(record.get(18)).setScale(2, RoundingMode.HALF_UP); // 堆积密度
            BigDecimal compactDensity510 = new BigDecimal(record.get(19)).setScale(2, RoundingMode.HALF_UP); // 紧密密度
            BigDecimal bulkDensity510 = new BigDecimal(record.get(20)).setScale(2, RoundingMode.HALF_UP); // 表观密度
            String regionName = record.get(21); // 来源地区

            Integer regionName510 = Integer.parseInt(regionName);

            // 构造一个唯一的键（直接拼接）
            String keyModelStone510 = modelstone510 + "-" + stoneSpecification510 + "-" + stackingDensity510 + "-" + compactDensity510 + "-" + bulkDensity510 + "-" + regionName510;
            System.out.println("key: " + key);

            Integer stone510Id;
            // 判断是否存在该记录
            if (sysStonMap.containsKey(keyModelStone510)) {
                stone510Id = sysStonMap.get(keyModelStone510).getStoneId();  // 使用正确的字段名称
              //  System.out.println("数据库已经存在水泥数据stone510Id" + stone510Id);
            } else {
                // 创建 SysStone 对象并加入临时列表
                SysStone sysStone = new SysStone();
                sysStone.setModel(modelstone510);
                sysStone.setStoneSpecification(stoneSpecification510);
                sysStone.setStackingDensity(stackingDensity510);
                sysStone.setCompactDensity(compactDensity510);
                sysStone.setBulkDensity(bulkDensity510);
                sysStone.setRegionName(regionName510);
                sysStone.setId(IdUtils.generateRandomNumber());

                sysStoneService.save(sysStone);
                sysStonMap.put(keyModelStone510, sysStone);
                stone510Id = sysStone.getStoneId();
               // System.out.println("新增石头数据，id = " + stone510Id);
            }


            /*石头石5-25mm----------------------------*/


            //String stone525 = record.get(22);// 石头5-10掺量
            BigDecimal stone525 = new BigDecimal(record.get(22));// 石头5-10掺量
            stone525 = stone525.setScale(2, RoundingMode.HALF_UP);




            /*石头5-10*/
            // 解析数据并保证两位小数
            String modelstone525 = record.get(23); // 型号
            String stoneSpecification525 = record.get(24); // 石子规格
            BigDecimal stackingDensity525 = new BigDecimal(record.get(25)).setScale(2, RoundingMode.HALF_UP); // 堆积密度
            BigDecimal compactDensity525 = new BigDecimal(record.get(26)).setScale(2, RoundingMode.HALF_UP); // 紧密密度
            BigDecimal bulkDensity525 = new BigDecimal(record.get(27)).setScale(2, RoundingMode.HALF_UP); // 表观密度
            String regionName525 = record.get(28); // 来源地区
            Integer regionName525s = Integer.parseInt(regionName525);

            // 构造一个唯一的键（直接拼接）
            String keyModelStone525 = modelstone525 + "-" + stoneSpecification525 + "-" + stackingDensity525 + "-" + compactDensity525 + "-" + bulkDensity525 + "-" + regionName525s;
            System.out.println("key: " + key);

            Integer stone525Id;
            // 判断是否存在该记录
            if (sysStonMap.containsKey(keyModelStone525)) {
                stone525Id = sysStonMap.get(keyModelStone525).getStoneId();  // 使用正确的字段名称
             //   System.out.println("数据库已经存在石头数据stone510Id" + stone525Id);
            } else {
                // 创建 SysStone 对象并加入临时列表
                SysStone sysStone = new SysStone();
                sysStone.setModel(modelstone525);
                sysStone.setStoneSpecification(stoneSpecification525);
                sysStone.setStackingDensity(stackingDensity525);
                sysStone.setCompactDensity(compactDensity525);
                sysStone.setBulkDensity(bulkDensity525);
                sysStone.setRegionName(regionName525s);
                sysStone.setId(IdUtils.generateRandomNumber());

                sysStoneService.save(sysStone);
                sysStonMap.put(keyModelStone525, sysStone);
                stone525Id = sysStone.getStoneId();
             //   System.out.println("新增石头数据stone525，id = " + stone525Id);
            }

            /*石头石20-40mm----------------------------*/

            // String stone2040 = record.get(29);// 石头20-40掺量

            BigDecimal stone2040 = new BigDecimal(record.get(29));// 石头20-40掺量
            stone2040 = stone2040.setScale(2, RoundingMode.HALF_UP);



            /*石头5-10*/
            // 解析数据并保证两位小数
            String modelstone2040 = record.get(30); // 型号
            String stoneSpecification2040 = record.get(31); // 石子规格
            BigDecimal stackingDensity2040 = new BigDecimal(record.get(32)).setScale(2, RoundingMode.HALF_UP); // 堆积密度
            BigDecimal compactDensity2040 = new BigDecimal(record.get(33)).setScale(2, RoundingMode.HALF_UP); // 紧密密度
            BigDecimal bulkDensity2040 = new BigDecimal(record.get(34)).setScale(2, RoundingMode.HALF_UP); // 表观密度
            String regionName2040 = record.get(35); // 来源地区
            Integer regionName2040s = Integer.parseInt(regionName2040);

            // 构造一个唯一的键（直接拼接）
            String keyModelStone2040 = modelstone2040 + "-" + stoneSpecification2040 + "-" + stackingDensity2040 + "-" + compactDensity2040 + "-" + bulkDensity2040 + "-" + regionName2040s;
           // System.out.println("key: " + keyModelStone2040);

            Integer stone2040Id;
            // 判断是否存在该记录
            if (sysStonMap.containsKey(keyModelStone2040)) {
                stone2040Id = sysStonMap.get(keyModelStone2040).getStoneId();  // 使用正确的字段名称
              //  System.out.println("数据库已经存在石头数据stone2040Id" + stone2040Id);
            } else {
                // 创建 SysStone 对象并加入临时列表
                SysStone sysStone = new SysStone();
                sysStone.setModel(modelstone2040);
                sysStone.setStoneSpecification(stoneSpecification2040);
                sysStone.setStackingDensity(stackingDensity2040);
                sysStone.setCompactDensity(compactDensity2040);
                sysStone.setBulkDensity(bulkDensity2040);
                sysStone.setRegionName(regionName2040s);
                sysStone.setId(IdUtils.generateRandomNumber());
                sysStoneService.save(sysStone);
                sysStonMap.put(keyModelStone2040, sysStone);
                stone2040Id = sysStone.getStoneId();
             //   System.out.println("新增石头数据stone525，id = " + stone2040Id);
            }


            /*石头20-20*/

            //  String stone1020 = record.get(36);// 石头10-50掺量

            BigDecimal stone1020 = new BigDecimal(record.get(36));// 石头5-10掺量
            stone1020 = stone1020.setScale(2, RoundingMode.HALF_UP);


            /*石头5-10*/
            // 解析数据并保证两位小数
            String modelstone1020 = record.get(37); // 型号
            String stoneSpecification1020 = record.get(38); // 石子规格
            BigDecimal stackingDensity1020 = new BigDecimal(record.get(39)).setScale(2, RoundingMode.HALF_UP); // 堆积密度
            BigDecimal compactDensity1020 = new BigDecimal(record.get(40)).setScale(2, RoundingMode.HALF_UP); // 紧密密度
            BigDecimal bulkDensity1020 = new BigDecimal(record.get(41)).setScale(2, RoundingMode.HALF_UP); // 表观密度
            String regionName1020 = record.get(42); // 来源地区
            Integer regionName1020s = Integer.parseInt(regionName1020);

            // 构造一个唯一的键（直接拼接）
            String keyModelStone1020 = modelstone1020 + "-" + stoneSpecification1020 + "-" + stackingDensity1020 + "-" + compactDensity1020 + "-" + bulkDensity1020 + "-" + regionName1020s;
            System.out.println("key: " + keyModelStone1020);

            Integer stone1020Id;
            // 判断是否存在该记录
            if (sysStonMap.containsKey(keyModelStone1020)) {
                stone1020Id = sysStonMap.get(keyModelStone1020).getStoneId();  // 使用正确的字段名称
             //   System.out.println("数据库已经存在石头数据stone2040Id" + stone1020Id);
            } else {
                // 创建 SysStone 对象并加入临时列表
                SysStone sysStone = new SysStone();
                sysStone.setModel(modelstone1020);
                sysStone.setStoneSpecification(stoneSpecification1020);
                sysStone.setStackingDensity(stackingDensity1020);
                sysStone.setCompactDensity(compactDensity1020);
                sysStone.setBulkDensity(bulkDensity1020);
                sysStone.setRegionName(regionName1020s);
                sysStone.setId(IdUtils.generateRandomNumber());
                sysStoneService.save(sysStone);
                sysStonMap.put(keyModelStone2040, sysStone);
                stone1020Id = sysStone.getStoneId();
              //  System.out.println("新增石头数据stone1020，id = " + stone1020Id);
            }

            /*石头10-30*/

            // String stone1030 = record.get(43);// 石头10-30掺量

            BigDecimal stone1030 = new BigDecimal(record.get(43));// 石头10-30掺量
            stone1030 = stone1030.setScale(2, RoundingMode.HALF_UP);


            // 解析数据并保证两位小数
            String modelstone1030 = record.get(44); // 型号
            String stoneSpecification1030 = record.get(45); // 石子规格
            BigDecimal stackingDensity1030 = new BigDecimal(record.get(46)).setScale(2, RoundingMode.HALF_UP); // 堆积密度
            BigDecimal compactDensity1030 = new BigDecimal(record.get(47)).setScale(2, RoundingMode.HALF_UP); // 紧密密度
            BigDecimal bulkDensity1030 = new BigDecimal(record.get(48)).setScale(2, RoundingMode.HALF_UP); // 表观密度
            String regionName1030 = record.get(49); // 来源地区
            Integer regionName1030s = Integer.parseInt(regionName1030);

            // 构造一个唯一的键（直接拼接）
            String keyModelStone1030 = modelstone1030 + "-" + stoneSpecification1030 + "-" + stackingDensity1030 + "-" + compactDensity1030 + "-" + bulkDensity1030 + "-" + regionName1030s;
            System.out.println("key: " + keyModelStone1030);

            Integer stone1030Id;
            // 判断是否存在该记录
            if (sysStonMap.containsKey(keyModelStone1030)) {
                stone1030Id = sysStonMap.get(keyModelStone1030).getStoneId();  // 使用正确的字段名称
              //  System.out.println("数据库已经存在石头数据stone2040Id" + stone1030Id);
            } else {
                // 创建 SysStone 对象并加入临时列表
                SysStone sysStone = new SysStone();
                sysStone.setModel(modelstone1030);
                sysStone.setStoneSpecification(stoneSpecification1030);
                sysStone.setStackingDensity(stackingDensity1030);
                sysStone.setCompactDensity(compactDensity1030);
                sysStone.setBulkDensity(bulkDensity1030);
                sysStone.setRegionName(regionName1030s);
                sysStone.setId(IdUtils.generateRandomNumber());
                sysStoneService.save(sysStone);
                sysStonMap.put(keyModelStone1030, sysStone);
                stone1030Id = sysStone.getStoneId();
              //  System.out.println("新增石头数据stone1020，id = " + stone1030Id);
            }

            /*石头0-10*/

            //String stone010 = record.get(50);// 石头0-10掺量

            BigDecimal stone010 = new BigDecimal(record.get(50));//石头0-10掺
            stone010 = stone010.setScale(2, RoundingMode.HALF_UP);


            // 解析数据并保证两位小数
            String modelstone010 = record.get(51); // 型号
            String stoneSpecification010 = record.get(52); // 石子规格
            BigDecimal stackingDensity010 = new BigDecimal(record.get(53)).setScale(2, RoundingMode.HALF_UP); // 堆积密度
            BigDecimal compactDensity010 = new BigDecimal(record.get(54)).setScale(2, RoundingMode.HALF_UP); // 紧密密度
            BigDecimal bulkDensity010 = new BigDecimal(record.get(55)).setScale(2, RoundingMode.HALF_UP); // 表观密度
            String regionName010 = record.get(56); // 来源地区
            Integer regionName010s = Integer.parseInt(regionName010);

            // 构造一个唯一的键（直接拼接）
            String keyModelStone010 = modelstone010 + "-" + stoneSpecification010 + "-" + stackingDensity010 + "-" + compactDensity010 + "-" + bulkDensity010 + "-" + regionName010s;
            System.out.println("key: " + keyModelStone1030);

            Integer stone010Id;
            // 判断是否存在该记录
            if (sysStonMap.containsKey(keyModelStone010)) {
                stone010Id = sysStonMap.get(keyModelStone010).getStoneId();  // 使用正确的字段名称
             //   System.out.println("数据库已经存在石头数据stone010Id" + stone010Id);
            } else {
                // 创建 SysStone 对象并加入临时列表
                SysStone sysStone = new SysStone();
                sysStone.setModel(modelstone010);
                sysStone.setStoneSpecification(stoneSpecification010);
                sysStone.setStackingDensity(stackingDensity010);
                sysStone.setCompactDensity(compactDensity010);
                sysStone.setBulkDensity(bulkDensity010);
                sysStone.setRegionName(regionName010s);
                sysStone.setId(IdUtils.generateRandomNumber());
                sysStoneService.save(sysStone);
                sysStonMap.put(keyModelStone010, sysStone);
                stone010Id = sysStone.getStoneId();
             //   System.out.println("新增石头数据stone010，id = " + stone010Id);
            }




            /*石头20-315*/

            //  String stone20315 = record.get(57);// 石头20-315掺量

            BigDecimal stone20315 = new BigDecimal(record.get(57));// 石头5-10掺量
            stone20315 = stone20315.setScale(2, RoundingMode.HALF_UP);


            // 解析数据并保证两位小数
            String modelstone20315 = record.get(58); // 型号
            String stoneSpecification20315 = record.get(59); // 石子规格
            BigDecimal stackingDensity20315 = new BigDecimal(record.get(60)).setScale(2, RoundingMode.HALF_UP); // 堆积密度
            BigDecimal compactDensity20315 = new BigDecimal(record.get(61)).setScale(2, RoundingMode.HALF_UP); // 紧密密度
            BigDecimal bulkDensity20315 = new BigDecimal(record.get(62)).setScale(2, RoundingMode.HALF_UP); // 表观密度
            String regionName20315 = record.get(63); // 来源地区
            Integer regionName20315s = Integer.parseInt(regionName20315);

            // 构造一个唯一的键（直接拼接）
            String keyModelStone20315 = modelstone20315 + "-" + stoneSpecification20315 + "-" + stackingDensity20315 + "-" + compactDensity20315 + "-" + bulkDensity20315 + "-" + regionName20315s;
            System.out.println("key: " + keyModelStone20315);

            Integer stone20315Id;
            // 判断是否存在该记录
            if (sysStonMap.containsKey(keyModelStone20315)) {
                stone20315Id = sysStonMap.get(keyModelStone20315).getStoneId();  // 使用正确的字段名称
               // System.out.println("数据库已经存在石头数据stone20315Id" + stone20315Id);
            } else {
                // 创建 SysStone 对象并加入临时列表
                SysStone sysStone = new SysStone();
                sysStone.setModel(modelstone20315);
                sysStone.setStoneSpecification(stoneSpecification20315);
                sysStone.setStackingDensity(stackingDensity20315);
                sysStone.setCompactDensity(compactDensity20315);
                sysStone.setBulkDensity(bulkDensity20315);
                sysStone.setRegionName(regionName20315s);
                sysStone.setId(IdUtils.generateRandomNumber());
                sysStoneService.save(sysStone);
                sysStonMap.put(keyModelStone20315, sysStone);
                stone20315Id = sysStone.getStoneId();
             //   System.out.println("新增石头数据stone010，id = " + stone20315Id);
            }

            /*河沙粗 31-37*/
            // String sand3137 = record.get(64);//砂3137参量

            BigDecimal sand3137 = new BigDecimal(record.get(64));// 石头5-10掺量
            sand3137 = sand3137.setScale(2, RoundingMode.HALF_UP);


            // 解析数据
            String sandModel3137 = record.get(65);  // 砂3137型号
            BigDecimal sandFineness3137 = new BigDecimal(record.get(66));  // 砂3137细度
            BigDecimal sandBulkDensity3137 = new BigDecimal(record.get(67));  // 砂3137堆积密度 (kg/m3)
            BigDecimal sandCompactDensity3137 = new BigDecimal(record.get(68));  // 砂3137紧密密度 (kg/m3)
            BigDecimal sandApparentDensity3137 = new BigDecimal(record.get(69));  // 砂3137表观密度 (kg/m3)

            String sandParticleSizeDistribution = record.get(70);  //砂3137 粒径分布(mm)
            int regionSand3137 = Integer.parseInt(record.get(71));

            // 确保所有 BigDecimal 保留两位小数
            sandFineness3137 = sandFineness3137.setScale(2, RoundingMode.HALF_UP);
            sandBulkDensity3137 = sandBulkDensity3137.setScale(2, RoundingMode.HALF_UP);
            sandCompactDensity3137 = sandCompactDensity3137.setScale(2, RoundingMode.HALF_UP);
            sandApparentDensity3137 = sandApparentDensity3137.setScale(2, RoundingMode.HALF_UP);

            // 构造一个唯一的键（唯一标识记录的组合字段）
            String keySand3137 = sandModel3137 + "-" + sandFineness3137 + "-" + sandBulkDensity3137 + "-" + sandCompactDensity3137 + "-" + sandApparentDensity3137 + "-"
                    + sandParticleSizeDistribution + "-" + regionSand3137;
           // System.out.println("key: " + keySand3137);


            Integer sand3137Id;
            // 判断是否存在该记录
            if (sysSandMap.containsKey(keySand3137)) {
                sand3137Id = sysSandMap.get(keySand3137).getSandId();  // 使用正确的字段名称
              //  System.out.println("数据库已经存在砂数据sand3137Id" + sand3137Id);

            } else {
                // 创建 SysSand 对象并加入临时列表
                SysSand sysSand = new SysSand();
                sysSand.setType(sandModel3137);
                sysSand.setFineness(sandFineness3137);
                sysSand.setBulkDensity(sandBulkDensity3137);
                sysSand.setCompactDensity(sandCompactDensity3137);
                sysSand.setApparentDensity(sandApparentDensity3137);
                sysSand.setParticleSizeDistribution(sandParticleSizeDistribution);
                sysSand.setRegionName(regionSand3137);
                sysSand.setId(IdUtils.generateRandomNumber());

                sysSandService.save(sysSand);
                sysSandMap.put(keySand3137, sysSand);
                sand3137Id = sysSand.getSandId();

               // System.out.println("新增砂头数据sandId3137，id = " + sand3137Id);
            }

            /*河沙粗 23-30*/

            // String sand2330 = record.get(72);//砂3137参量
            BigDecimal sand2330 = new BigDecimal(record.get(72));// 石头5-10掺量
            sand2330 = sand2330.setScale(2, RoundingMode.HALF_UP);


            // 解析数据
            String sandModel2330 = record.get(73);  // 砂3137型号
            BigDecimal sandFineness2330 = new BigDecimal(record.get(74));  // 砂3137细度
            BigDecimal sandBulkDensity2330 = new BigDecimal(record.get(75));  // 砂3137堆积密度 (kg/m3)
            BigDecimal sandCompactDensity2330 = new BigDecimal(record.get(76));  // 砂3137紧密密度 (kg/m3)
            BigDecimal sandApparentDensity2330 = new BigDecimal(record.get(77));  // 砂3137表观密度 (kg/m3)
            String sandParticleSizeDistribution2330 = record.get(78);  //砂3137 粒径分布(mm)
            int regionSand2330 = Integer.parseInt(record.get(79));
            // 确保所有 BigDecimal 保留两位小数
            sandFineness2330 = sandFineness2330.setScale(2, RoundingMode.HALF_UP);
            sandBulkDensity2330 = sandBulkDensity2330.setScale(2, RoundingMode.HALF_UP);
            sandCompactDensity2330 = sandCompactDensity2330.setScale(2, RoundingMode.HALF_UP);
            sandApparentDensity2330 = sandApparentDensity2330.setScale(2, RoundingMode.HALF_UP);

            // 构造一个唯一的键（唯一标识记录的组合字段）
            String keySand2330 = sandModel2330 + "-" + sandFineness2330 + "-" + sandBulkDensity2330 + "-" + sandCompactDensity2330 + "-" + sandApparentDensity2330 + "-"
                    + sandParticleSizeDistribution2330 + "-" + regionSand2330;
           // System.out.println("key: " + keySand2330);


            Integer sand2330Id;
            // 判断是否存在该记录
            if (sysSandMap.containsKey(keySand2330)) {
                sand2330Id = sysSandMap.get(keySand2330).getSandId();  // 使用正确的字段名称
             //   System.out.println("数据库已经存在砂数据sand2330Id" + sand2330Id);

            } else {
                // 创建 SysSand 对象并加入临时列表
                SysSand sysSand = new SysSand();
                sysSand.setType(sandModel2330);
                sysSand.setFineness(sandFineness2330);
                sysSand.setBulkDensity(sandBulkDensity2330);
                sysSand.setCompactDensity(sandCompactDensity2330);
                sysSand.setApparentDensity(sandApparentDensity2330);
                sysSand.setParticleSizeDistribution(sandParticleSizeDistribution2330);
                sysSand.setRegionName(regionSand2330);
                sysSand.setId(IdUtils.generateRandomNumber());

                sysSandService.save(sysSand);
                sysSandMap.put(keySand2330, sysSand);
                sand2330Id = sysSand.getSandId();

              //  System.out.println("新增砂头数据sand2330Id，id = " + sand2330Id);
            }

            /*河砂细16-22mm*/

            // String sand1622 = record.get(80);//砂316 22参量

            BigDecimal sand1622 = new BigDecimal(record.get(80));// 石头5-10掺量
            sand1622 = sand1622.setScale(2, RoundingMode.HALF_UP);


            // 解析数据
            String sandModel1622 = record.get(81);  // 砂3137型号
            BigDecimal sandFineness1622 = new BigDecimal(record.get(82));  // 砂3137细度
            BigDecimal sandBulkDensity1622 = new BigDecimal(record.get(83));  // 砂3137堆积密度 (kg/m3)
            BigDecimal sandCompactDensity1622 = new BigDecimal(record.get(84));  // 砂3137紧密密度 (kg/m3)
            BigDecimal sandApparentDensity1622 = new BigDecimal(record.get(85));  // 砂3137表观密度 (kg/m3)
            String sandParticleSizeDistribution1622 = record.get(86);  //砂3137 粒径分布(mm)
            int regionSand1622 = Integer.parseInt(record.get(87));
            // 确保所有 BigDecimal 保留两位小数
            sandFineness1622 = sandFineness1622.setScale(2, RoundingMode.HALF_UP);
            sandBulkDensity1622 = sandBulkDensity1622.setScale(2, RoundingMode.HALF_UP);
            sandCompactDensity1622 = sandCompactDensity1622.setScale(2, RoundingMode.HALF_UP);
            sandApparentDensity1622 = sandApparentDensity1622.setScale(2, RoundingMode.HALF_UP);

            // 构造一个唯一的键（唯一标识记录的组合字段）
            String keySand1622 = sandModel1622 + "-" + sandFineness1622 + "-" + sandBulkDensity1622 + "-" + sandCompactDensity1622 + "-" + sandApparentDensity1622 + "-"
                    + sandParticleSizeDistribution1622 + "-" + regionSand1622;
            System.out.println("key: " + keySand1622);


            Integer sand1622Id;
            // 判断是否存在该记录
            if (sysSandMap.containsKey(keySand1622)) {
                sand1622Id = sysSandMap.get(keySand1622).getSandId();  // 使用正确的字段名称
              //  System.out.println("数据库已经存在砂数据sand1622Id" + sand1622Id);

            } else {
                // 创建 SysSand 对象并加入临时列表
                SysSand sysSand = new SysSand();
                sysSand.setType(sandModel1622);
                sysSand.setFineness(sandFineness1622);
                sysSand.setBulkDensity(sandBulkDensity1622);
                sysSand.setCompactDensity(sandCompactDensity1622);
                sysSand.setApparentDensity(sandApparentDensity1622);
                sysSand.setParticleSizeDistribution(sandParticleSizeDistribution1622);
                sysSand.setRegionName(regionSand2330);
                sysSand.setId(IdUtils.generateRandomNumber());

                sysSandService.save(sysSand);
                sysSandMap.put(keySand1622, sysSand);
                sand1622Id = sysSand.getSandId();

             //   System.out.println("新增砂头数据sand1622Id，id = " + sand1622Id);
            }
            /*机制砂中23-30Bmm*/
            //  String sand2330B = record.get(88);//砂3137参量
            BigDecimal sand2330B = new BigDecimal(record.get(88));// 机制砂中23-30B
            sand2330B = sand2330B.setScale(2, RoundingMode.HALF_UP);


            // 解析数据
            String sandModel2330B = record.get(89);  // 砂3137型号
            BigDecimal sandFineness2330B = new BigDecimal(record.get(90));  // 砂3137细度
            BigDecimal sandBulkDensity2330B = new BigDecimal(record.get(91));  // 砂3137堆积密度 (kg/m3)
            BigDecimal sandCompactDensity2330B = new BigDecimal(record.get(92));  // 砂3137紧密密度 (kg/m3)
            BigDecimal sandApparentDensity2330B = new BigDecimal(record.get(93));  // 砂3137表观密度 (kg/m3)
            String sandParticleSizeDistribution2330B = record.get(94);  //砂3137 粒径分布(mm)
            int regionSand2330B = Integer.parseInt(record.get(95));
            // 确保所有 BigDecimal 保留两位小数
            sandFineness2330B = sandFineness2330B.setScale(2, RoundingMode.HALF_UP);
            sandBulkDensity2330B = sandBulkDensity2330B.setScale(2, RoundingMode.HALF_UP);
            sandCompactDensity2330B = sandCompactDensity2330B.setScale(2, RoundingMode.HALF_UP);
            sandApparentDensity2330B = sandApparentDensity2330B.setScale(2, RoundingMode.HALF_UP);

            // 构造一个唯一的键（唯一标识记录的组合字段）
            String keySand2330B = sandModel2330B + "-" + sandFineness2330B + "-" + sandBulkDensity2330B + "-" + sandCompactDensity2330B + "-" + sandApparentDensity2330B + "-"
                    + sandParticleSizeDistribution2330B + "-" + regionSand2330B;
           // System.out.println("key: " + keySand2330B);


            Integer sand2330BId;
            // 判断是否存在该记录
            if (sysSandMap.containsKey(keySand2330B)) {
                sand2330BId = sysSandMap.get(keySand2330B).getSandId();  // 使用正确的字段名称
             //   System.out.println("数据库已经存在砂数据sand1622Id" + sand2330BId);

            } else {
                // 创建 SysSand 对象并加入临时列表
                SysSand sysSand = new SysSand();
                sysSand.setType(sandModel2330B);
                sysSand.setFineness(sandFineness2330B);
                sysSand.setBulkDensity(sandBulkDensity2330B);
                sysSand.setCompactDensity(sandCompactDensity2330B);
                sysSand.setApparentDensity(sandApparentDensity2330B);
                sysSand.setParticleSizeDistribution(sandParticleSizeDistribution2330B);
                sysSand.setRegionName(regionSand2330B);
                sysSand.setId(IdUtils.generateRandomNumber());

                sysSandService.save(sysSand);
                sysSandMap.put(keySand2330B, sysSand);
                sand2330BId = sysSand.getSandId();
             //   System.out.println("新增砂头数据sand1622Id，id = " + sand2330BId);
            }


            /*机制粗中31-37Bmm*/
            // String sand3137B = record.get(96);//砂3137参量

            BigDecimal sand3137B = new BigDecimal(record.get(96));// 石头5-10掺量
            sand3137B = sand3137B.setScale(2, RoundingMode.HALF_UP);


            // 解析数据
            String sandModel3137B = record.get(97);  // 砂3137型号
            BigDecimal sandFineness3137B = new BigDecimal(record.get(98));  // 砂3137细度
            BigDecimal sandBulkDensity3137B = new BigDecimal(record.get(99));  // 砂3137堆积密度 (kg/m3)
            BigDecimal sandCompactDensity3137B = new BigDecimal(record.get(100));  // 砂3137紧密密度 (kg/m3)
            BigDecimal sandApparentDensity3137B = new BigDecimal(record.get(101));  // 砂3137表观密度 (kg/m3)
            String sandParticleSizeDistribution3137B = record.get(102);  //砂3137 粒径分布(mm)
            int regionSand3137B = Integer.parseInt(record.get(103));
            // 确保所有 BigDecimal 保留两位小数
            sandFineness3137B = sandFineness3137B.setScale(2, RoundingMode.HALF_UP);
            sandBulkDensity3137B = sandBulkDensity3137B.setScale(2, RoundingMode.HALF_UP);
            sandCompactDensity3137B = sandCompactDensity3137B.setScale(2, RoundingMode.HALF_UP);
            sandApparentDensity3137B = sandApparentDensity3137B.setScale(2, RoundingMode.HALF_UP);

            // 构造一个唯一的键（唯一标识记录的组合字段）
            String keySand3137B = sandModel3137B + "-" + sandFineness3137B + "-" + sandBulkDensity3137B + "-" + sandCompactDensity3137B + "-" + sandApparentDensity3137B + "-"
                    + sandParticleSizeDistribution3137B + "-" + regionSand3137B;
          //  System.out.println("key: " + keySand2330B);


            Integer sand3137BId;
            // 判断是否存在该记录
            if (sysSandMap.containsKey(keySand3137B)) {
                sand3137BId = sysSandMap.get(keySand3137B).getSandId();  // 使用正确的字段名称
               // System.out.println("数据库已经存在砂数据sand1622Id" + sand3137BId);

            } else {
                // 创建 SysSand 对象并加入临时列表
                SysSand sysSand = new SysSand();
                sysSand.setType(sandModel3137B);
                sysSand.setFineness(sandFineness3137B);
                sysSand.setBulkDensity(sandBulkDensity3137B);
                sysSand.setCompactDensity(sandCompactDensity3137B);
                sysSand.setApparentDensity(sandApparentDensity3137B);
                sysSand.setParticleSizeDistribution(sandParticleSizeDistribution3137B);
                sysSand.setRegionName(regionSand3137B);
                sysSand.setId(IdUtils.generateRandomNumber());

                sysSandService.save(sysSand);
                sysSandMap.put(keySand3137B, sysSand);
                sand3137BId = sysSand.getSandId();
              //  System.out.println("新增砂头数据sand1622Id，id = " + sand3137BId);
            }

            /*机制砂细16-22Bmm*/
            // String sand1622B = record.get(104);//砂3137参量

            BigDecimal sand1622B = new BigDecimal(record.get(104));// 石头5-10掺量
            sand1622B = sand1622B.setScale(2, RoundingMode.HALF_UP);


            // 解析数据
            String sandModel1622B = record.get(105);  // 砂3137型号
            BigDecimal sandFineness1622B = new BigDecimal(record.get(106));  // 砂3137细度
            BigDecimal sandBulkDensity1622B = new BigDecimal(record.get(107));  // 砂3137堆积密度 (kg/m3)
            BigDecimal sandCompactDensity1622B = new BigDecimal(record.get(108));  // 砂3137紧密密度 (kg/m3)
            BigDecimal sandApparentDensity1622B = new BigDecimal(record.get(109));  // 砂3137表观密度 (kg/m3)
            String sandParticleSizeDistribution1622B = record.get(110);  //砂3137 粒径分布(mm)
            int regionSand1622B = Integer.parseInt(record.get(111));
            // 确保所有 BigDecimal 保留两位小数
            sandFineness1622B = sandFineness1622B.setScale(2, RoundingMode.HALF_UP);
            sandBulkDensity1622B = sandBulkDensity1622B.setScale(2, RoundingMode.HALF_UP);
            sandCompactDensity1622B = sandCompactDensity1622B.setScale(2, RoundingMode.HALF_UP);
            sandApparentDensity1622B = sandApparentDensity1622B.setScale(2, RoundingMode.HALF_UP);

            // 构造一个唯一的键（唯一标识记录的组合字段）
            String keySand1622B = sandModel1622B + "-" + sandFineness1622B + "-" + sandBulkDensity1622B + "-" + sandCompactDensity1622B + "-" + sandApparentDensity1622B + "-"
                    + sandParticleSizeDistribution1622B + "-" + regionSand1622B;
            System.out.println("key: " + keySand2330B);


            Integer sand1622BId;
            // 判断是否存在该记录
            if (sysSandMap.containsKey(keySand1622B)) {
                sand1622BId = sysSandMap.get(keySand1622B).getSandId();  // 使用正确的字段名称
              //  System.out.println("数据库已经存在砂数据sand1622Id" + sand1622BId);

            } else {
                // 创建 SysSand 对象并加入临时列表
                SysSand sysSand = new SysSand();
                sysSand.setType(sandModel1622B);
                sysSand.setFineness(sandFineness1622B);
                sysSand.setBulkDensity(sandBulkDensity1622B);
                sysSand.setCompactDensity(sandCompactDensity1622B);
                sysSand.setApparentDensity(sandApparentDensity1622B);
                sysSand.setParticleSizeDistribution(sandParticleSizeDistribution1622B);
                sysSand.setRegionName(regionSand1622B);
                sysSand.setId(IdUtils.generateRandomNumber());

                sysSandService.save(sysSand);
                sysSandMap.put(keySand1622B, sysSand);
                sand1622BId = sysSand.getSandId();
             //   System.out.println("新增砂头数据sand1622Id，id = " + sand1622BId);
            }


            /*砂0475*/
            // String sand0475 = record.get(112);//砂3137参量

            BigDecimal sand0475 = new BigDecimal(record.get(112));// 石头5-10掺量
            sand0475 = sand0475.setScale(2, RoundingMode.HALF_UP);


            // 解析数据
            String sandModel0475 = record.get(113);  // 砂3137型号
            BigDecimal sandFineness0475 = new BigDecimal(record.get(114));  // 砂3137细度
            BigDecimal sandBulkDensity0475 = new BigDecimal(record.get(115));  // 砂3137堆积密度 (kg/m3)
            BigDecimal sandCompactDensity0475 = new BigDecimal(record.get(116));  // 砂3137紧密密度 (kg/m3)
            BigDecimal sandApparentDensity0475 = new BigDecimal(record.get(117));  // 砂3137表观密度 (kg/m3)
            String sandParticleSizeDistribution0475 = record.get(118);  //砂3137 粒径分布(mm)
            int regionSand0475 = Integer.parseInt(record.get(119));
            // 确保所有 BigDecimal 保留两位小数
            sandFineness0475 = sandFineness0475.setScale(2, RoundingMode.HALF_UP);
            sandBulkDensity0475 = sandBulkDensity0475.setScale(2, RoundingMode.HALF_UP);
            sandCompactDensity0475 = sandCompactDensity0475.setScale(2, RoundingMode.HALF_UP);
            sandApparentDensity0475 = sandApparentDensity0475.setScale(2, RoundingMode.HALF_UP);

            // 构造一个唯一的键（唯一标识记录的组合字段）
            String keySand0475 = sandModel0475 + "-" + sandFineness0475 + "-" + sandBulkDensity0475 + "-" + sandCompactDensity0475 + "-" + sandApparentDensity0475 + "-"
                    + sandParticleSizeDistribution0475 + "-" + regionSand0475;
            //System.out.println("key: " + keySand2330B);


            Integer sand0475Id;
            // 判断是否存在该记录
            if (sysSandMap.containsKey(keySand0475)) {
                sand0475Id = sysSandMap.get(keySand0475).getSandId();  // 使用正确的字段名称
              //  System.out.println("数据库已经存在砂数据sand1622Id" + sand0475Id);

            } else {
                // 创建 SysSand 对象并加入临时列表
                SysSand sysSand = new SysSand();
                sysSand.setType(sandModel0475);
                sysSand.setFineness(sandFineness0475);
                sysSand.setBulkDensity(sandBulkDensity0475);
                sysSand.setCompactDensity(sandCompactDensity0475);
                sysSand.setApparentDensity(sandApparentDensity0475);
                sysSand.setParticleSizeDistribution(sandParticleSizeDistribution0475);
                sysSand.setRegionName(regionSand0475);
                sysSand.setId(IdUtils.generateRandomNumber());

                sysSandService.save(sysSand);
                sysSandMap.put(keySand0475, sysSand);
                sand0475Id = sysSand.getSandId();
               // System.out.println("新增砂头数据sand1622Id，id = " + sand0475Id);
            }

            /*砂09*/
            //String sand09 = record.get(120);//砂3137参量

            BigDecimal sand09 = new BigDecimal(record.get(120));// 石头5-10掺量
            sand09 = sand09.setScale(2, RoundingMode.HALF_UP);


            // 解析数据
            String sandModel09 = record.get(121);  // 砂3137型号
            BigDecimal sandFineness09 = new BigDecimal(record.get(122));  // 砂3137细度
            BigDecimal sandBulkDensity09 = new BigDecimal(record.get(123));  // 砂3137堆积密度 (kg/m3)
            BigDecimal sandCompactDensity09 = new BigDecimal(record.get(124));  // 砂3137紧密密度 (kg/m3)
            BigDecimal sandApparentDensity09 = new BigDecimal(record.get(125));  // 砂3137表观密度 (kg/m3)
            String sandParticleSizeDistribution09 = record.get(126);  //砂3137 粒径分布(mm)
            int regionSand09 = Integer.parseInt(record.get(127));
            // 确保所有 BigDecimal 保留两位小数
            sandFineness09 = sandFineness09.setScale(2, RoundingMode.HALF_UP);
            sandBulkDensity09 = sandBulkDensity09.setScale(2, RoundingMode.HALF_UP);
            sandCompactDensity09 = sandCompactDensity09.setScale(2, RoundingMode.HALF_UP);
            sandApparentDensity09 = sandApparentDensity09.setScale(2, RoundingMode.HALF_UP);

            // 构造一个唯一的键（唯一标识记录的组合字段）
            String keySand09 = sandModel09 + "-" + sandFineness09 + "-" + sandBulkDensity09 + "-" + sandCompactDensity09 + "-" + sandApparentDensity09 + "-"
                    + sandParticleSizeDistribution09 + "-" + regionSand09;
            System.out.println("key: " + keySand09);


            Integer sand09Id;
            // 判断是否存在该记录
            if (sysSandMap.containsKey(keySand09)) {
                sand09Id = sysSandMap.get(keySand09).getSandId();  // 使用正确的字段名称
            //    System.out.println("数据库已经存在砂数据sand1622Id" + sand09Id);

            } else {
                // 创建 SysSand 对象并加入临时列表
                SysSand sysSand = new SysSand();
                sysSand.setType(sandModel09);
                sysSand.setFineness(sandFineness09);
                sysSand.setBulkDensity(sandBulkDensity09);
                sysSand.setCompactDensity(sandCompactDensity09);
                sysSand.setApparentDensity(sandApparentDensity09);
                sysSand.setParticleSizeDistribution(sandParticleSizeDistribution09);
                sysSand.setRegionName(regionSand09);
                sysSand.setId(IdUtils.generateRandomNumber());

                sysSandService.save(sysSand);
                sysSandMap.put(keySand09, sysSand);
                sand09Id = sysSand.getSandId();
              //  System.out.println("新增砂头数据sand1622Id，id = " + sand09Id);
            }

            /* 石粉*/

            // String otherAdmixturesStonePowder = record.get(128);//石粉用量
            BigDecimal otherAdmixturesStonePowder = new BigDecimal(record.get(128));// 石头5-10掺量
            otherAdmixturesStonePowder = otherAdmixturesStonePowder.setScale(2, RoundingMode.HALF_UP);


            // 解析数据
            String otherAdmixturesModel = record.get(129);//型号

            BigDecimal otherAdmixturesFineness = new BigDecimal(record.get(130));//细度
            BigDecimal otherAdmixturesMoistureContent = new BigDecimal(record.get(131));//含水量
            BigDecimal otherAdmixturesActivityIndex28d = new BigDecimal(record.get(132));//28天活性指数(%)

            int otherAdmixturesRegionName = Integer.parseInt(record.get(133));//来源地区

            // 确保所有 BigDecimal 保留两位小数
            otherAdmixturesFineness = otherAdmixturesFineness.setScale(2, RoundingMode.HALF_UP);
            otherAdmixturesMoistureContent = otherAdmixturesMoistureContent.setScale(2, RoundingMode.HALF_UP);
            otherAdmixturesActivityIndex28d = otherAdmixturesActivityIndex28d.setScale(2, RoundingMode.HALF_UP);

            // 构造一个唯一的键
            String otherAdmixturesKey = otherAdmixturesModel + "-" + otherAdmixturesFineness + "-" + otherAdmixturesMoistureContent + "-" + otherAdmixturesActivityIndex28d + "-" + otherAdmixturesRegionName;
            System.out.println("key" + otherAdmixturesKey);


            Integer otherAdmixturesId;
            // 判断是否存在该记录
            if (sysOtherAdmixturesMap.containsKey(otherAdmixturesKey)) {
                otherAdmixturesId = sysOtherAdmixturesMap.get(otherAdmixturesKey).getAdmixturesId();  // 使用正确的字段名称
             //   System.out.println("数据库已经存在砂数据otherAdmixturesId" + otherAdmixturesId);
            } else {


                SysOtherAdmixtures sysOtherAdmixtures = new SysOtherAdmixtures();
                sysOtherAdmixtures.setModel(otherAdmixturesModel);
                sysOtherAdmixtures.setFineness(otherAdmixturesFineness);
                sysOtherAdmixtures.setMoistureContent(otherAdmixturesMoistureContent);
                sysOtherAdmixtures.setActivityIndex28d(otherAdmixturesActivityIndex28d);
                sysOtherAdmixtures.setRegionName(otherAdmixturesRegionName);
                sysOtherAdmixtures.setCreateTime(Timestamp.valueOf(LocalDateTime.now()));
                sysOtherAdmixtures.setId(IdUtils.generateRandomNumber());

                sysOtherAdmixturesService.save(sysOtherAdmixtures);
                sysOtherAdmixturesMap.put(otherAdmixturesKey, sysOtherAdmixtures);

                otherAdmixturesId = sysOtherAdmixtures.getAdmixturesId();
             //   System.out.println("新增砂头数据otherAdmixturesId，id = " + otherAdmixturesId);
            }

            /*矿粉*/
            //  String mineralPowder = record.get(134);//矿粉掺量
            BigDecimal mineralPowder = new BigDecimal(record.get(134));// 石头5-10掺量
            mineralPowder = mineralPowder.setScale(2, RoundingMode.HALF_UP);


            String mineralPowderModel = record.get(135);//矿粉型号
            String mineralPowderSlagGrade = record.get(136);//矿粉等级

            BigDecimal mineralPowderFineness = new BigDecimal(record.get(137));//细度(%)
            BigDecimal mineralPowderMoistureContent = new BigDecimal(record.get(138));//含水量
            BigDecimal mineralPowderActivityIndex28d = new BigDecimal(record.get(139));//28天活性指数(%)
            int mineralPowderRegionName = Integer.parseInt(record.get(140));//来源地区

            // 确保所有 BigDecimal 保留两位小数
            mineralPowderFineness = mineralPowderFineness.setScale(2, RoundingMode.HALF_UP);
            mineralPowderMoistureContent = mineralPowderMoistureContent.setScale(2, RoundingMode.HALF_UP);
            mineralPowderActivityIndex28d = mineralPowderActivityIndex28d.setScale(2, RoundingMode.HALF_UP);

            String keyMineralPowder = mineralPowderModel + "-" + mineralPowderSlagGrade + "-" + mineralPowderFineness + "-" + mineralPowderMoistureContent + "-" + mineralPowderActivityIndex28d + "-" + mineralPowderRegionName;
            Integer mineralPowderId;
            // 判断是否存在该记录
            if (MineralPowderMap.containsKey(keyMineralPowder)) {
                mineralPowderId = MineralPowderMap.get(keyMineralPowder).getPowderId();  // 使用正确的字段名称
              //  System.out.println("数据库已经存在矿粉数据mineralPowderId" + mineralPowderId);
            } else {

                SysMineralPowder powder = new SysMineralPowder();
                powder.setModel(mineralPowderModel);
                powder.setSlagGrade(mineralPowderSlagGrade);
                powder.setFineness(mineralPowderFineness);
                powder.setMoistureContent(mineralPowderMoistureContent);
                powder.setActivityIndex28d(mineralPowderActivityIndex28d);
                powder.setRegionName(mineralPowderRegionName);
                powder.setCreateTime(Timestamp.valueOf(LocalDateTime.now()));
                powder.setId(IdUtils.generateRandomNumber());

                sysMineralPowderService.save(powder);
                MineralPowderMap.put(otherAdmixturesKey, powder);

                mineralPowderId = powder.getPowderId();

             //   System.out.println("新增矿粉数据mineralPowderId，id = " + mineralPowderId);
            }

            /*粉煤灰*/
            //String flyash = record.get(141);//粉煤灰掺量

            BigDecimal flyash = new BigDecimal(record.get(141));// 石头5-10掺量
            flyash = flyash.setScale(2, RoundingMode.HALF_UP);


            String flyashModel = record.get(142);//粉煤灰型号
            String flyashfactoryGrade = record.get(143);//粉煤灰出厂等级

            BigDecimal flyashFineness = new BigDecimal(record.get(144));//粉煤灰细度(%)
            BigDecimal flyashMoistureContent = new BigDecimal(record.get(145));//粉煤灰含水量
            BigDecimal flyashActivityIndex28d = new BigDecimal(record.get(146));//粉煤灰28天活性指数(%)
            int flyashRegionName = Integer.parseInt(record.get(147));//粉煤灰来源地区

            // 确保所有 BigDecimal 保留两位小数
            flyashFineness = flyashFineness.setScale(2, RoundingMode.HALF_UP);
            flyashMoistureContent = flyashMoistureContent.setScale(2, RoundingMode.HALF_UP);
            flyashActivityIndex28d = flyashActivityIndex28d.setScale(2, RoundingMode.HALF_UP);
            // 构造一个唯一的键
            String keyFlyash = flyashModel + "-" + flyashfactoryGrade + "-" + flyashFineness + "-" + flyashMoistureContent + "-" + flyashActivityIndex28d + "-" + flyashRegionName;


            Integer flyashId;
            // 判断是否存在该记录
            if (flyashMap.containsKey(keyFlyash)) {
                flyashId = flyashMap.get(keyFlyash).getFlyashId();
             //   System.out.println("数据库已经存在矿粉数据flyashId" + flyashId);
            } else {

                SysFlyash sysFlyash = new SysFlyash();
                sysFlyash.setGrade(flyashModel);
                sysFlyash.setFactoryGrade(flyashfactoryGrade);
                sysFlyash.setFineness(flyashFineness);
                sysFlyash.setMoistureContent(flyashMoistureContent);
                sysFlyash.setActivityIndex28d(flyashActivityIndex28d);
                sysFlyash.setRegionName(flyashRegionName);
                sysFlyash.setCreateTime(Timestamp.valueOf(LocalDateTime.now()));
                sysFlyash.setId(IdUtils.generateRandomNumber());
                sysFlyashService.save(sysFlyash);

                flyashMap.put(keyFlyash, sysFlyash);
                flyashId = sysFlyash.getFlyashId();


             //   System.out.println("新增矿粉数据flyashId，id = " + flyashId);
            }


            /*减水剂*/

            // String waterReducer = record.get(148);//减水剂参量
            BigDecimal waterReducer = new BigDecimal(record.get(148));// 石头5-10掺量
            waterReducer = waterReducer.setScale(2, RoundingMode.HALF_UP);


            String WaterReducermodel = record.get(149);//减水剂型号

            BigDecimal WaterReducersolidContent = new BigDecimal(record.get(150));//含固量(%)
            BigDecimal WaterReducercementPasteFlow = new BigDecimal(record.get(151));//水泥净浆流动度(mm)
            BigDecimal WaterReducerreducingRate = new BigDecimal(record.get(152));//减水率

            String WaterReducerRegionName = record.get(153);//来源地区

            // 确保所有 BigDecimal 保留两位小数
            WaterReducersolidContent = WaterReducersolidContent.setScale(2, RoundingMode.HALF_UP);
            WaterReducercementPasteFlow = WaterReducercementPasteFlow.setScale(2, RoundingMode.HALF_UP);
            WaterReducerreducingRate = WaterReducerreducingRate.setScale(2, RoundingMode.HALF_UP);
            // 构造一个唯一的键
            String keyWaterReducer = WaterReducermodel + "-" + WaterReducersolidContent + "-" + WaterReducercementPasteFlow + "-" + WaterReducerreducingRate + "-" + WaterReducerRegionName;
            System.out.println("减水剂插入数据" + keyWaterReducer);
            Integer waterReducerId;
            if (sysWaterReducerMap.containsKey(keyWaterReducer)) {
                waterReducerId = sysWaterReducerMap.get(keyWaterReducer).getReducerId();
              //  System.out.println("减水剂 记录已存在（字段完全相同），跳过插入: " + waterReducerId);
            } else {

                SysWaterReducer sysWaterReducer = new SysWaterReducer();
                sysWaterReducer.setModel(WaterReducermodel);
                sysWaterReducer.setSolidContent(WaterReducersolidContent);
                sysWaterReducer.setCementPasteFlow(WaterReducercementPasteFlow);
                sysWaterReducer.setReducingRate(WaterReducerreducingRate);
                sysWaterReducer.setSourceName(WaterReducerRegionName);

                sysWaterReducer.setCreateTime(Timestamp.valueOf(LocalDateTime.now()));
                sysWaterReducer.setId(IdUtils.generateRandomNumber());
                sysWaterReducerService.save(sysWaterReducer);

                sysWaterReducerMap.put(keyWaterReducer, sysWaterReducer);

                waterReducerId = sysWaterReducer.getReducerId();


             //   System.out.println("新增减水剂数据reducerId，id = " + waterReducerId);
            }

            /*增效剂*/
            //  String efficiencyAgent = record.get(154);//增效剂掺量

            BigDecimal efficiencyAgent = new BigDecimal(record.get(154));// 石头5-10掺量
            efficiencyAgent = efficiencyAgent.setScale(2, RoundingMode.HALF_UP);


            String efficiencyAgentModel = record.get(155);//增效剂型号
            String efficiencyAgentRegionName = record.get(156);//增效剂来源

            String efficiencyAgentKey = efficiencyAgentModel + "-" + efficiencyAgentRegionName;
            Integer efficiencyAgentId;
            if (efficiencyAgentMap.containsKey(efficiencyAgentKey)) {
                efficiencyAgentId = efficiencyAgentMap.get(efficiencyAgentKey).getAgentId();
             //   System.out.println("记录已存在（字段完全相同），跳过插入: " + efficiencyAgentId);
            } else {
                SysEfficiencyAgent sysEfficiencyAgent = new SysEfficiencyAgent();
                sysEfficiencyAgent.setModel(efficiencyAgentModel);
                sysEfficiencyAgent.setSourceName(efficiencyAgentRegionName);
                sysEfficiencyAgent.setCreateTime(Timestamp.valueOf(LocalDateTime.now()));
                sysEfficiencyAgent.setDeleteTime(0);
                sysEfficiencyAgent.setId(IdUtils.generateRandomNumber());

                sysEfficiencyAgentService.save(sysEfficiencyAgent);

                efficiencyAgentMap.put(efficiencyAgentKey, sysEfficiencyAgent);
                efficiencyAgentId = sysEfficiencyAgent.getAgentId();


              //  System.out.println("新增增效剂数据efficiencyAgentId，id = " + efficiencyAgentId);
            }


            // String swellinAagent = record.get(157);//膨胀剂掺量型号
            BigDecimal swellinAagent = new BigDecimal(record.get(157));// 石头5-10掺量
            swellinAagent = swellinAagent.setScale(2, RoundingMode.HALF_UP);


            String swellingAgentmodel = record.get(158);//型号
            String swellingAgentRegionName = record.get(159);//来源地区


            // 构造一个唯一的键
            String keySwellingagent = swellingAgentmodel + "-" + swellingAgentRegionName;
           // System.out.println("哈哈哈key" + key);
            // 判断是否存在该记录

            Integer sysSwellingId;
            if (SysSwellingMap.containsKey(keySwellingagent)) {
                sysSwellingId = SysSwellingMap.get(keySwellingagent).getSwellingagentId();
             //   System.out.println("记录已存在（字段完全相同），跳过插入: " + sysSwellingId);
            } else {
                SysSwellingagent sysSwellingagent = new SysSwellingagent();
                sysSwellingagent.setModel(swellingAgentmodel);
                sysSwellingagent.setSourceName(swellingAgentRegionName);
                sysSwellingagent.setCreateTime(Timestamp.valueOf(LocalDateTime.now()));
                sysSwellingagent.setDeleteTime(0);
                sysSwellingagent.setId(IdUtils.generateRandomNumber());

                sysSwellingagentService.save(sysSwellingagent);
                SysSwellingMap.put(keySwellingagent, sysSwellingagent);
                sysSwellingId = sysSwellingagent.getSwellingagentId();

               // System.out.println("新增膨胀剂数据sysSwellingId，id = " + sysSwellingId);
            }


            //SysMechanicalPerformance sysMechanicalPerformance = new SysMechanicalPerformance();
            SysSlump sysMechanicalPerformance = new SysSlump();
            sysMechanicalPerformance.setCementId(cementId);//1
            sysMechanicalPerformance.setStone510Id(stone510Id);//2
            sysMechanicalPerformance.setStone525Id(stone525Id);//3
            sysMechanicalPerformance.setStone2040Id(stone2040Id);//4
            sysMechanicalPerformance.setStone1020Id(stone1020Id);//5
            sysMechanicalPerformance.setStone1030Id(stone1030Id);//6
            sysMechanicalPerformance.setStone010Id(stone010Id);//7
            sysMechanicalPerformance.setStone2031Id(stone20315Id);//8
            sysMechanicalPerformance.setSandRiverCoarse3137Id(sand3137Id);//9
            sysMechanicalPerformance.setSandRiver2330MedId(sand2330Id);//10
            sysMechanicalPerformance.setSandRiver1622FineId(sand1622Id);//11
            sysMechanicalPerformance.setSandMech2330MedId(sand2330BId);//12
            sysMechanicalPerformance.setSandMech3137CoarseId(sand3137BId);//13
            sysMechanicalPerformance.setSandMech1622FineId(sand1622BId);//14
            sysMechanicalPerformance.setSandMech0475Id(sand0475Id);//15
            sysMechanicalPerformance.setSandMech09Id(sand09Id);//16
            sysMechanicalPerformance.setStonePowderId(otherAdmixturesId);//17
            sysMechanicalPerformance.setMineralPowderId(mineralPowderId);//18
            sysMechanicalPerformance.setFlyAshId(flyashId);//19
            sysMechanicalPerformance.setWaterReducerId(waterReducerId);//20
            sysMechanicalPerformance.setEfficiencyAgentId(efficiencyAgentId);//21
            sysMechanicalPerformance.setExpansionAgentId(sysSwellingId);//22
            sysMechanicalPerformance.setSlump(slump);

            batchInsertList.add(sysMechanicalPerformance);//


            //插入力学性能
            // 获取所有已存在的力学性能数据
//            LambdaQueryWrapper<SysMechanicalPerformance> wrapperSysMechanicalPerformance = new LambdaQueryWrapper<>();
//            List<SysMechanicalPerformance> listwrapperSysMechanicalPerformance = sysMechanicalPerformanceService.list(wrapperSysMechanicalPerformance);
//            Map<String, SysMechanicalPerformance> wrapperSysMechanicalPerformanceMap = new HashMap<>();

            LambdaQueryWrapper<SysSlump> wrapperSysMechanicalPerformance = new LambdaQueryWrapper<>();
            List<SysSlump> listwrapperSysMechanicalPerformance = sysSlumpService.list(wrapperSysMechanicalPerformance);
            Map<String, SysSlump> wrapperSysMechanicalPerformanceMap = new HashMap<>();


            // 将数据库中的所有数据按唯一组合键存入 Map
            for (SysSlump sysCement : listwrapperSysMechanicalPerformance) {
                String keySysMechanicalPerformance =
                        sysCement.getCementId() + "-" +
                                sysCement.getStone510Id() + "-" +
                                sysCement.getStone525Id() + "-" +
                                sysCement.getStone2040Id() + "-" +
                                sysCement.getStone1020Id() + "-" +
                                sysCement.getStone1030Id() + "-" +
                                sysCement.getStone010Id() + "-" +
                                sysCement.getStone2031Id() + "-" +
                                sysCement.getSandRiverCoarse3137Id() + "-" +
                                sysCement.getSandRiver2330MedId() + "-" +
                                sysCement.getSandRiver1622FineId() + "-" +
                                sysCement.getSandMech2330MedId() + "-" +
                                sysCement.getSandMech3137CoarseId() + "-" +
                                sysCement.getSandMech1622FineId() + "-" +
                                sysCement.getSandMech0475Id() + "-" +
                                sysCement.getSandMech09Id() + "-" +
                                sysCement.getStonePowderId() + "-" +
                                sysCement.getMineralPowderId() + "-" +
                                sysCement.getFlyAshId() + "-" +
                                sysCement.getWaterReducerId() + "-" +
                                sysCement.getEfficiencyAgentId() + "-" +
                                sysCement.getExpansionAgentId() + "-" +

                                sysCement.getWater() + "-" +
                                sysCement.getCement() + "-" +
                                sysCement.getStone510() + "-" +
                                sysCement.getStone525() + "-" +
                                sysCement.getStone2040() + "-" +
                                sysCement.getStone1020() + "-" +
                                sysCement.getStone1030() + "-" +
                                sysCement.getStone010() + "-" +
                                sysCement.getStoneCoarse20315() + "-" +
                                sysCement.getSandRiverCoarse3137() + "-" +
                                sysCement.getSandRiver2330Med() + "-" +
                                sysCement.getSandRiver1622Fine() + "-" +
                                sysCement.getSandMech2330Med() + "-" +
                                sysCement.getSandMech3137Coarse() + "-" +
                                sysCement.getSandMech1622Fine() + "-" +
                                sysCement.getSandMech0475() + "-" +
                                sysCement.getSandMech09() + "-" +
                                sysCement.getStonePowder() + "-" +
                                sysCement.getMineralPowder() + "-" +
                                sysCement.getFlyAsh() + "-" +
                                sysCement.getWaterReducer() + "-" +
                                sysCement.getEfficiencyAgent() + "-" +
                                sysCement.getExpansionAgent() + "-" +
                                sysCement.getRegion() + "-" +
                                sysCement.getProductionDate() + "-" +
                                sysCement.getSlump();

                wrapperSysMechanicalPerformanceMap.put(keySysMechanicalPerformance, sysCement);  // 使用一个唯一的组合键作为 map 的 key
            }
           // System.out.println("数据库中的key" + wrapperSysMechanicalPerformanceMap);  // 打印生成的 key

            // 创建一个列表用于存储待插入的新数据
            List<SysSlump> newDataList = new ArrayList<>();
            // 构建新的唯一键
            String keySysMechanicalPerformance = cementId + "-" + stone510Id + "-" + stone525Id + "-" + stone2040Id + "-" + stone1020Id + "-"
                    + stone1030Id + "-" + stone010Id + "-" + stone20315Id + "-" + sand3137Id + "-" + sand2330Id + "-"
                    + sand1622Id + "-" + sand2330BId + "-" + sand3137BId + "-" + sand1622BId + "-" + sand0475Id + "-"
                    + sand09Id + "-" + otherAdmixturesId + "-" + mineralPowderId + "-" + flyashId + "-"
                    + waterReducerId + "-" + efficiencyAgentId + "-" + sysSwellingId + "-" + water + "-" + cement
                    + "-" + stone510 + "-" + stone525 + "-" + stone2040 + "-" + stone1020 + "-" + stone1030 + "-" + stone010 + "-" +
                    stone20315 + "-" + sand3137 + "-" + sand2330 + "-" + sand1622 + "-" + sand2330B + "-" + sand3137B + "-" + sand1622B + "-" + sand0475 + "-" +
                    sand09 + "-" + otherAdmixturesStonePowder + "-" + mineralPowder + "-" + flyash + "-" + waterReducer + "-" + efficiencyAgent + "-" + swellinAagent + "-" +
                    regiona + "-" + productionDate + "-" + slump;


            System.out.println("现在的key" + keySysMechanicalPerformance);
            // 检查是否已经存在相同的力学性能数据
            if (wrapperSysMechanicalPerformanceMap.containsKey(keySysMechanicalPerformance)) {
                // 数据已存在，跳过插入
             //   System.out.println("力学性能数据已存在，跳过啦哈哈哈哈哈");
            } else {
                // 数据不存在，插入新数据
                // SysMechanicalPerformance newSysMechanicalPerformance = new SysMechanicalPerformance();

                SysSlump newSysMechanicalPerformance = new SysSlump();
                newSysMechanicalPerformance.setCementId(cementId);
                newSysMechanicalPerformance.setStone510Id(stone510Id);
                newSysMechanicalPerformance.setStone525Id(stone525Id);
                newSysMechanicalPerformance.setStone2040Id(stone2040Id);
                newSysMechanicalPerformance.setStone1020Id(stone1020Id);
                newSysMechanicalPerformance.setStone1030Id(stone1030Id);
                newSysMechanicalPerformance.setStone010Id(stone010Id);
                newSysMechanicalPerformance.setStone2031Id(stone20315Id);
                newSysMechanicalPerformance.setSandRiverCoarse3137Id(sand3137Id);
                newSysMechanicalPerformance.setSandRiver2330MedId(sand2330Id);
                newSysMechanicalPerformance.setSandRiver1622FineId(sand1622Id);
                newSysMechanicalPerformance.setSandMech2330MedId(sand2330BId);
                newSysMechanicalPerformance.setSandMech3137CoarseId(sand3137BId);
                newSysMechanicalPerformance.setSandMech1622FineId(sand1622BId);
                newSysMechanicalPerformance.setSandMech0475Id(sand0475Id);
                newSysMechanicalPerformance.setSandMech09Id(sand09Id);
                newSysMechanicalPerformance.setStonePowderId(otherAdmixturesId);
                newSysMechanicalPerformance.setMineralPowderId(mineralPowderId);
                newSysMechanicalPerformance.setFlyAshId(flyashId);
                newSysMechanicalPerformance.setWaterReducerId(waterReducerId);
                newSysMechanicalPerformance.setEfficiencyAgentId(efficiencyAgentId);
                newSysMechanicalPerformance.setExpansionAgentId(sysSwellingId);//22

                newSysMechanicalPerformance.setWater(water);
                newSysMechanicalPerformance.setCement(cement);
                newSysMechanicalPerformance.setStone510(stone510);
                newSysMechanicalPerformance.setStone525(stone525);
                newSysMechanicalPerformance.setStone2040(stone2040);
                newSysMechanicalPerformance.setStone1020(stone1020);
                newSysMechanicalPerformance.setStone1030(stone1030);
                newSysMechanicalPerformance.setStone010(stone010);
                newSysMechanicalPerformance.setStoneCoarse20315(stone20315);
                newSysMechanicalPerformance.setSandRiverCoarse3137(sand3137);
                newSysMechanicalPerformance.setSandRiver2330Med(sand2330);
                newSysMechanicalPerformance.setSandRiver1622Fine(sand1622);
                newSysMechanicalPerformance.setSandMech2330Med(sand2330B);
                newSysMechanicalPerformance.setSandMech3137Coarse(sand3137B);

                newSysMechanicalPerformance.setSandMech1622Fine(sand1622B);
                newSysMechanicalPerformance.setSandMech0475(sand0475);
                newSysMechanicalPerformance.setSandMech09(sand09);

                newSysMechanicalPerformance.setStonePowder(otherAdmixturesStonePowder);

                newSysMechanicalPerformance.setMineralPowder(mineralPowder);
                newSysMechanicalPerformance.setFlyAsh(flyash);
                newSysMechanicalPerformance.setWaterReducer(waterReducer);

                newSysMechanicalPerformance.setEfficiencyAgent(efficiencyAgent);
                newSysMechanicalPerformance.setExpansionAgent(swellinAagent);

                /* 掺量结束*/
                newSysMechanicalPerformance.setRegion(regiona);
                newSysMechanicalPerformance.setProductionDate(productionDate);
                newSysMechanicalPerformance.setSlump(slump);
//                newSysMechanicalPerformance.setStrengthGrade(strengthGrade);
//
//
//                newSysMechanicalPerformance.setCompressive3d(compressive3d);
//                newSysMechanicalPerformance.setCompressive7d(compressive7d);
//                newSysMechanicalPerformance.setCompressive28d(compressive28d);
                newSysMechanicalPerformance.setCreateTime(LocalDateTime.now());

                newDataList.add(newSysMechanicalPerformance);
                // 插入新数据
            //    sysSlumpService.save(newSysMechanicalPerformance);


              //  System.out.println("力学性能数据不存在，已插入哈哈哈哈哈");
            }
            // 批量插入数据（如果有新数据需要插入）
            if (!newDataList.isEmpty()) {
                sysSlumpService.saveBatch(newDataList);
               // System.out.println("成功批量插入" + newDataList.size() + "条坍落度数据");
            }


                //审核之后写入excel 地址放入数据库
            updateMechanicalExcelUrlAfterApproval0();

        }

        return AjaxResult.success();
    }


/*---------------------------------------------------------------*/

    public void updateMechanicalExcelUrlAfterApproval0() {
        try {
            // 成功之后url放入数据库
            String url = slumpUrl();
            // 查询数据库中所有记录
            List<SysMaterialSlumpUrl> records = sysMaterialSlumpUrlService.list();
            if (records != null && records.size() > 1) {
                // 如果存在至少两条记录，获取第二条记录(索引为1)
                SysMaterialSlumpUrl sysMaterialSlumpUrl = records.get(1);
                // 只更新slumpUrl字段，其他字段保持不变
                sysMaterialSlumpUrl.setSlumpUrl(url);
                // 执行更新
                sysMaterialSlumpUrlService.updateById(sysMaterialSlumpUrl);
            } else {
                // 记录不足两条，不执行任何操作
                log.warn("记录数量不足，无法更新第二条记录");
            }
        } catch (Exception e) {
            log.error("更新坍落度Excel路径失败", e);
        }
    }





public  String slumpUrl(){
    // 查询力学性能数据
    List<SysSlump> agentList = sysSlumpService.list();
    // 获取地区信息，转换成 Map 以便后续使用
    List<Region> listRegion = regionService.list();
    Map<Integer, Region> regionMap = listRegion.stream()
            .collect(Collectors.toMap(Region::getId, Function.identity()));

    // 获取水泥信息，转换成 Map 以便后续使用
    List<SysCement> listCement = sysCementService.list();
    Map<Integer, SysCement> CementMap = listCement.stream()
            .collect(Collectors.toMap(SysCement::getCementId, Function.identity()));


    // 获取水泥信息，转换成 Map 以便后续使用
    List<SysStone> listStone = sysStoneService.list();
    Map<Integer, SysStone> StoneMap = listStone.stream()
            .collect(Collectors.toMap(SysStone::getStoneId, Function.identity()));


    // 获取砂信息，转换成 Map 以便后续使用
    List<SysSand> listSande = sysSandService.list();
    Map<Integer, SysSand> SandeMap = listSande.stream()
            .collect(Collectors.toMap(SysSand::getSandId, Function.identity()));


    // 获取石粉信息，转换成 Map 以便后续使用
    List<SysOtherAdmixtures> listOtherAdmixtures = sysOtherAdmixturesService.list();
    Map<Integer, SysOtherAdmixtures> OtherAdmixturesMap = listOtherAdmixtures.stream()
            .collect(Collectors.toMap(SysOtherAdmixtures::getAdmixturesId, Function.identity()));


    // 获取矿粉信息，转换成 Map 以便后续使用
    List<SysMineralPowder> listMineralPowder = sysMineralPowderService.list();
    Map<Integer, SysMineralPowder> SysMineralPowderMap = listMineralPowder.stream()
            .collect(Collectors.toMap(SysMineralPowder::getPowderId, Function.identity()));

    // 获取粉煤灰信息，转换成 Map 以便后续使用
    List<SysFlyash> listFlyash = sysFlyashService.list();
    Map<Integer, SysFlyash> flyashMap = listFlyash.stream()
            .collect(Collectors.toMap(SysFlyash::getFlyashId, Function.identity()));


    // 获取减水剂信息，转换成 Map 以便后续使用
    List<SysWaterReducer> listSysWaterReducer = sysWaterReducerService.list();
    Map<Integer, SysWaterReducer> SysWaterReducerMap = listSysWaterReducer.stream()
            .collect(Collectors.toMap(SysWaterReducer::getReducerId, Function.identity()));


    // 获取增效剂信息，转换成 Map 以便后续使用
    List<SysEfficiencyAgent> listEfficiencyAgent = sysEfficiencyAgent.list();
    Map<Integer, SysEfficiencyAgent> efficiencyAgentMap = listEfficiencyAgent.stream()
            .collect(Collectors.toMap(SysEfficiencyAgent::getAgentId, Function.identity()));


    // 获取膨胀剂信息，转换成 Map 以便后续使用
    List<SysSwellingagent> listSwellingagent = sysSwellingagentService.list();
    Map<Integer, SysSwellingagent> swellingagentMap = listSwellingagent.stream()
            .collect(Collectors.toMap(SysSwellingagent::getSwellingagentId, Function.identity()));


    // 准备返回的 VO 列表
    List<SysMechanicalPerformanceFourthVO> agentVOList = new ArrayList<>();
    for (SysSlump smp : agentList) {
        SysMechanicalPerformanceFourthVO vo = new SysMechanicalPerformanceFourthVO();
        BeanUtils.copyProperties(smp, vo);

        // 设置地区名称
        Integer regionId = smp.getRegion();
        Region region = regionMap.get(regionId);
        if (region != null) {
            vo.setRegionNameStr(region.getFullName());
        }

        LocalDateTime productionDate = smp.getProductionDate();
        if (productionDate != null) {
            vo.setProductionDate(productionDate);
        }
        BigDecimal slump = smp.getSlump();
        vo.setStrengthGrade(slump);

        //查询水泥数据
        Integer cementId = smp.getCementId();
        if (cementId != null) {
            SysCement sysCement = CementMap.get(cementId);
            if (sysCement != null) {
                vo.setCementModel(sysCement.getModel());
                vo.setCementCaoContent(sysCement.getCaoContent());
                vo.setCementSio2Content(sysCement.getSio2Content());
                vo.setCementAl2o3Content(sysCement.getAl2o3Content());
                vo.setCementCompressiveStrength28d(sysCement.getCompressiveStrength28d());
                vo.setCementStrengthGrade(sysCement.getStrengthGrade());
                Integer regionName = sysCement.getRegionName();
                if (regionName != null) {
                    Region region1 = regionMap.get(regionName);
                    if (region1 != null) {
                        vo.setCementRegionNameStr(region1.getFullName());
                    }

                }
            }


        }


        //石头 5-10
        Integer stone510Id = smp.getStone510Id();
        if (stone510Id != null) {
            SysStone sysStone510 = StoneMap.get(stone510Id);
            if (sysStone510 != null) {
                System.out.println("哈哈哈510" + sysStone510);
                vo.setStoneModel510(sysStone510.getModel());
                vo.setStoneSpecification510(sysStone510.getStoneSpecification());
                vo.setStoneStackingDensity510(sysStone510.getStackingDensity());
                vo.setStoneCompactDensity510(sysStone510.getCompactDensity());
                vo.setStoneBulkdensity510(sysStone510.getBulkDensity());
                Integer regionNameStone510 = sysStone510.getRegionName();
                if (regionNameStone510 != null) {
                    Region region1 = regionMap.get(regionNameStone510);
                    if (region1 != null) {
                        vo.setStoneRegionNameStr510(region1.getFullName());
                    }
                }
            }

        }

        //石头 5-25
        Integer stone525Id = smp.getStone525Id();
        if (stone525Id != null) {
            SysStone sysStone525 = StoneMap.get(stone525Id);
            if (sysStone525 != null) {
                System.out.println("哈哈哈510" + sysStone525);
                vo.setStoneModel525(sysStone525.getModel());
                vo.setStoneSpecification525(sysStone525.getStoneSpecification());
                vo.setStoneStackingDensity525(sysStone525.getStackingDensity());
                vo.setStoneCompactDensity525(sysStone525.getCompactDensity());
                vo.setStoneBulkdensity525(sysStone525.getBulkDensity());
                Integer regionNameStone525 = sysStone525.getRegionName();
                if (regionNameStone525 != null) {
                    Region region1 = regionMap.get(regionNameStone525);
                    if (region1 != null) {
                        vo.setStoneRegionNameStr525(region1.getFullName());
                    }
                }
            }
        }


        //石头 2040
        Integer stone2040Id = smp.getStone525Id();
        if (stone2040Id != null) {
            SysStone sysStone2040 = StoneMap.get(stone2040Id);
            if (sysStone2040 != null) {
                System.out.println("哈哈哈510" + sysStone2040);
                vo.setStoneModel2040(sysStone2040.getModel());
                vo.setStoneSpecification2040(sysStone2040.getStoneSpecification());
                vo.setStoneStackingDensity2040(sysStone2040.getStackingDensity());
                vo.setStoneCompactDensity2040(sysStone2040.getCompactDensity());
                vo.setStoneBulkdensity2040(sysStone2040.getBulkDensity());
                Integer regionNameStone2040 = sysStone2040.getRegionName();
                if (regionNameStone2040 != null) {
                    Region region1 = regionMap.get(regionNameStone2040);
                    if (region1 != null) {
                        vo.setStoneRegionNameStr2040(region1.getFullName());
                    }
                }
            }
        }


        //石头 10-20
        Integer stone1020Id = smp.getStone1020Id();
        if (stone1020Id != null) {
            SysStone sysStone1020 = StoneMap.get(stone1020Id);
            if (sysStone1020 != null) {
                System.out.println("哈哈哈510" + sysStone1020);
                vo.setStoneModel1020(sysStone1020.getModel());
                vo.setStoneSpecification1020(sysStone1020.getStoneSpecification());
                vo.setStoneStackingDensity1020(sysStone1020.getStackingDensity());
                vo.setStoneCompactDensity1020(sysStone1020.getCompactDensity());
                vo.setStoneBulkdensity1020(sysStone1020.getBulkDensity());
                Integer regionNameStone1020 = sysStone1020.getRegionName();
                if (regionNameStone1020 != null) {
                    Region region1 = regionMap.get(regionNameStone1020);
                    if (region1 != null) {
                        vo.setStoneRegionNameStr1020(region1.getFullName());
                    }
                }
            }
        }


        //石头 10-30
        Integer stone1030Id = smp.getStone1030Id();
        if (stone1030Id != null) {
            SysStone sysStone1030 = StoneMap.get(stone1030Id);
            if (sysStone1030 != null) {
                System.out.println("哈哈哈510" + sysStone1030);
                vo.setStoneModel1030(sysStone1030.getModel());
                vo.setStoneSpecification1030(sysStone1030.getStoneSpecification());
                vo.setStoneStackingDensity1030(sysStone1030.getStackingDensity());
                vo.setStoneCompactDensity1030(sysStone1030.getCompactDensity());
                vo.setStoneBulkdensity1030(sysStone1030.getBulkDensity());
                Integer regionNameStone1030 = sysStone1030.getRegionName();
                if (regionNameStone1030 != null) {
                    Region region1 = regionMap.get(regionNameStone1030);
                    if (region1 != null) {
                        vo.setStoneRegionNameStr1030(region1.getFullName());
                    }
                }
            }
        }

        vo.setStone2031(smp.getStoneCoarse20315());
        //石头 0-10
        Integer stone010Id = smp.getStone010Id();
        if (stone010Id != null) {
            SysStone sysStone010 = StoneMap.get(stone010Id);
            if (sysStone010 != null) {

                vo.setStoneModel010(sysStone010.getModel());
                vo.setStoneSpecification010(sysStone010.getStoneSpecification());
                vo.setStoneStackingDensity010(sysStone010.getStackingDensity());
                vo.setStoneCompactDensity010(sysStone010.getCompactDensity());
                vo.setStoneBulkdensity010(sysStone010.getBulkDensity());
                Integer regionNameStone010 = sysStone010.getRegionName();
                if (regionNameStone010 != null) {
                    Region region1 = regionMap.get(regionNameStone010);
                    if (region1 != null) {
                        vo.setStoneRegionNameStr010(region1.getFullName());
                    }
                }
            }
        }

        //石头 20-315
        Integer stone20315Id = smp.getStone2031Id();
        if (stone20315Id != null) {
            SysStone sysStone20315 = StoneMap.get(stone20315Id);
            if (sysStone20315 != null) {

                vo.setStoneModel20315(sysStone20315.getModel());
                vo.setStoneSpecification20315(sysStone20315.getStoneSpecification());
                vo.setStoneStackingDensity20315(sysStone20315.getStackingDensity());
                vo.setStoneCompactDensity20315(sysStone20315.getCompactDensity());
                vo.setStoneBulkdensity20315(sysStone20315.getBulkDensity());
                Integer regionNameStone20315 = sysStone20315.getRegionName();
                if (regionNameStone20315 != null) {
                    Region region1 = regionMap.get(regionNameStone20315);
                    if (region1 != null) {
                        vo.setStoneRegionNameStr20315(region1.getFullName());
                    }
                }
            }
        }


        //砂31-37
        vo.setSand3137(smp.getSandRiverCoarse3137());
        Integer sandRiverCoarse3137Id = smp.getSandRiverCoarse3137Id();
        if (sandRiverCoarse3137Id != null) {
            SysSand sysSand3137 = SandeMap.get(sandRiverCoarse3137Id);
            if (sysSand3137 != null) {
                vo.setSandType3137(sysSand3137.getType());
                vo.setSandFineness3137(sysSand3137.getFineness());
                vo.setSandBulkDensity3137(sysSand3137.getBulkDensity());
                vo.setSandCompactDensity3137(sysSand3137.getCompactDensity());
                vo.setSandApparentDensity3137(sysSand3137.getApparentDensity());
                vo.setSandParticleSizeDistribution3137(sysSand3137.getParticleSizeDistribution());
                Integer regionName3137 = sysSand3137.getRegionName();
                if (regionName3137 != null) {
                    Region region1 = regionMap.get(regionName3137);
                    if (region1 != null) {
                        vo.setSandRegionNameStr3137(region1.getFullName());
                    }
                }


            }


        }


        //砂23-30
        vo.setSand2330(smp.getSandRiver2330Med());
        Integer sandRiverCoarse2330Id = smp.getSandRiver2330MedId();
        if (sandRiverCoarse2330Id != null) {
            SysSand sysSand2330 = SandeMap.get(sandRiverCoarse2330Id);
            if (sysSand2330 != null) {
                vo.setSandType2330(sysSand2330.getType());
                vo.setSandFineness2330(sysSand2330.getFineness());
                vo.setSandBulkDensity2330(sysSand2330.getBulkDensity());
                vo.setSandCompactDensity2330(sysSand2330.getCompactDensity());
                vo.setSandApparentDensity2330(sysSand2330.getApparentDensity());
                vo.setSandParticleSizeDistribution2330(sysSand2330.getParticleSizeDistribution());
                Integer regionName2330 = sysSand2330.getRegionName();
                if (regionName2330 != null) {
                    Region region1 = regionMap.get(regionName2330);
                    if (region1 != null) {
                        vo.setSandRegionNameStr2330(region1.getFullName());
                    }
                }


            }


        }


        //砂16-22
        vo.setSand1622(smp.getSandRiver1622Fine());
        Integer sandRiverCoarse1622Id = smp.getSandRiver1622FineId();
        if (sandRiverCoarse1622Id != null) {
            SysSand sysSand1622 = SandeMap.get(sandRiverCoarse1622Id);
            if (sysSand1622 != null) {
                vo.setSandType1622(sysSand1622.getType());
                vo.setSandFineness1622(sysSand1622.getFineness());
                vo.setSandBulkDensity1622(sysSand1622.getBulkDensity());
                vo.setSandCompactDensity1622(sysSand1622.getCompactDensity());
                vo.setSandApparentDensity1622(sysSand1622.getApparentDensity());
                vo.setSandParticleSizeDistribution1622(sysSand1622.getParticleSizeDistribution());
                Integer regionName1622 = sysSand1622.getRegionName();
                if (regionName1622 != null) {
                    Region region1 = regionMap.get(regionName1622);
                    if (region1 != null) {
                        vo.setSandRegionNameStr1622(region1.getFullName());
                    }
                }

            }

        }


        //砂2330B
        vo.setSand2330B(smp.getSandMech2330Med());
        Integer sandRiverCoarse2330BId = smp.getSandMech2330MedId();
        if (sandRiverCoarse2330BId != null) {
            SysSand sysSand2330B = SandeMap.get(sandRiverCoarse2330BId);
            if (sysSand2330B != null) {
                vo.setSandType2330B(sysSand2330B.getType());
                vo.setSandFineness2330B(sysSand2330B.getFineness());
                vo.setSandBulkDensity2330B(sysSand2330B.getBulkDensity());
                vo.setSandCompactDensity2330B(sysSand2330B.getCompactDensity());
                vo.setSandApparentDensity2330B(sysSand2330B.getApparentDensity());
                vo.setSandParticleSizeDistribution2330B(sysSand2330B.getParticleSizeDistribution());
                Integer regionName2330B = sysSand2330B.getRegionName();
                if (regionName2330B != null) {
                    Region region1 = regionMap.get(regionName2330B);
                    if (region1 != null) {
                        vo.setSandRegionNameStr2330B(region1.getFullName());
                    }
                }

            }

        }


        //砂31-37B
        vo.setSand3137B(smp.getSandMech3137Coarse());
        Integer sandRiverCoarse3137BId = smp.getSandMech3137CoarseId();
        if (sandRiverCoarse3137BId != null) {
            SysSand sysSand3137B = SandeMap.get(sandRiverCoarse3137BId);
            if (sysSand3137B != null) {
                vo.setSandType3137B(sysSand3137B.getType());
                vo.setSandFineness3137B(sysSand3137B.getFineness());
                vo.setSandBulkDensity3137B(sysSand3137B.getBulkDensity());
                vo.setSandCompactDensity3137B(sysSand3137B.getCompactDensity());
                vo.setSandApparentDensity3137B(sysSand3137B.getApparentDensity());
                vo.setSandParticleSizeDistribution3137B(sysSand3137B.getParticleSizeDistribution());
                Integer regionName3137B = sysSand3137B.getRegionName();
                if (regionName3137B != null) {
                    Region region1 = regionMap.get(regionName3137B);
                    if (region1 != null) {
                        vo.setSandRegionNameStr3137B(region1.getFullName());
                    }
                }

            }
        }


        //砂16-22
        vo.setSand1622B(smp.getSandMech1622Fine());
        Integer sandRiverCoarse1622BId = smp.getSandMech1622FineId();
        if (sandRiverCoarse1622BId != null) {
            SysSand sysSand1622B = SandeMap.get(sandRiverCoarse1622BId);
            if (sysSand1622B != null) {
                vo.setSandType1622B(sysSand1622B.getType());
                vo.setSandFineness1622B(sysSand1622B.getFineness());
                vo.setSandBulkDensity1622B(sysSand1622B.getBulkDensity());
                vo.setSandCompactDensity1622B(sysSand1622B.getCompactDensity());
                vo.setSandApparentDensity1622B(sysSand1622B.getApparentDensity());
                vo.setSandParticleSizeDistribution1622B(sysSand1622B.getParticleSizeDistribution());
                Integer regionName1622B = sysSand1622B.getRegionName();
                if (regionName1622B != null) {
                    Region region1 = regionMap.get(regionName1622B);
                    if (region1 != null) {
                        vo.setSandRegionNameStr1622B(region1.getFullName());
                    }
                }

            }

        }


        //砂04-75
        vo.setSand0475(smp.getSandMech0475());
        Integer sandRiverCoarse0475Id = smp.getSandMech0475Id();
        if (sandRiverCoarse0475Id != null) {
            SysSand sysSand0475 = SandeMap.get(sandRiverCoarse0475Id);
            if (sysSand0475 != null) {
                vo.setSandType0475(sysSand0475.getType());
                vo.setSandFineness0475(sysSand0475.getFineness());
                vo.setSandBulkDensity0475(sysSand0475.getBulkDensity());
                vo.setSandCompactDensity0475(sysSand0475.getCompactDensity());
                vo.setSandApparentDensity0475(sysSand0475.getApparentDensity());
                vo.setSandParticleSizeDistribution0475(sysSand0475.getParticleSizeDistribution());
                Integer regionName0475 = sysSand0475.getRegionName();
                if (regionName0475 != null) {
                    Region region1 = regionMap.get(regionName0475);
                    if (region1 != null) {
                        vo.setSandRegionNameStr0475(region1.getFullName());
                    }
                }

            }
        }

//砂0-9
        vo.setSand09(smp.getSandMech09());
        Integer sandRiverCoarse09Id = smp.getSandMech09Id();
        if (sandRiverCoarse09Id != null) {
            SysSand sysSand09 = SandeMap.get(sandRiverCoarse09Id);
            if (sysSand09 != null) {
                vo.setSandType09(sysSand09.getType());
                vo.setSandFineness09(sysSand09.getFineness());
                vo.setSandBulkDensity09(sysSand09.getBulkDensity());
                vo.setSandCompactDensity09(sysSand09.getCompactDensity());
                vo.setSandApparentDensity09(sysSand09.getApparentDensity());
                vo.setSandParticleSizeDistribution09(sysSand09.getParticleSizeDistribution());
                Integer regionName09 = sysSand09.getRegionName();
                if (regionName09 != null) {
                    Region region1 = regionMap.get(regionName09);
                    if (region1 != null) {
                        vo.setSandRegionNameStr09(region1.getFullName());
                    }
                }

            }
        }


        //石粉
        vo.setAdmixtures(smp.getStonePowder());
        Integer stonePowderId = smp.getStonePowderId();
        if (stonePowderId != null) {
            SysOtherAdmixtures sysOtherAdmixtures = OtherAdmixturesMap.get(stonePowderId);
            if (sysOtherAdmixtures != null) {
                vo.setAdmixturesModel(sysOtherAdmixtures.getModel());
                vo.setAdmixturesFineness(sysOtherAdmixtures.getFineness());
                vo.setAdmixturesMoistureContent(sysOtherAdmixtures.getMoistureContent());
                vo.setAdmixturesActivityIndex28d(sysOtherAdmixtures.getActivityIndex28d());
                Integer regionName09 = sysOtherAdmixtures.getRegionName();
                if (regionName09 != null) {
                    Region region1 = regionMap.get(regionName09);
                    if (region1 != null) {
                        vo.setAdmixturesRegionNameStr(region1.getFullName());
                    }
                }

            }
        }


        //矿粉
        vo.setMineralPowder(smp.getMineralPowder());
        Integer mineralPowderId = smp.getMineralPowderId();
        if (mineralPowderId != null) {
            SysMineralPowder sysMineralPowder = SysMineralPowderMap.get(mineralPowderId);
            if (sysMineralPowder != null) {
                vo.setMineralModel(sysMineralPowder.getModel());
                vo.setMineralSlagGrade(sysMineralPowder.getSlagGrade());
                vo.setMineralFineness(sysMineralPowder.getFineness());
                vo.setMineralMoistureContent(sysMineralPowder.getMoistureContent());
                vo.setMineralActivityIndex28d(sysMineralPowder.getActivityIndex28d());

                Integer regionName = sysMineralPowder.getRegionName();
                if (regionName != null) {
                    Region region1 = regionMap.get(regionName);
                    if (region1 != null) {
                        vo.setMineralRegionNameStr(region1.getFullName());
                    }
                }

            }
        }


        //粉煤灰
        vo.setFlyash(smp.getFlyAsh());
        Integer flyAshId = smp.getFlyAshId();
        if (flyAshId != null) {
            SysFlyash sysFlyash = flyashMap.get(flyAshId);
            if (sysFlyash != null) {
                vo.setFlyashGrade(sysFlyash.getGrade());
                vo.setFlyashFactoryGrade(sysFlyash.getFactoryGrade());
                vo.setFlyashFineness(sysFlyash.getFineness());
                vo.setFlyashMoistureContent(sysFlyash.getMoistureContent());
                vo.setFlyashActivityIndex28d(sysFlyash.getActivityIndex28d());

                Integer regionName = sysFlyash.getRegionName();
                if (regionName != null) {
                    Region region1 = regionMap.get(regionName);
                    if (region1 != null) {
                        vo.setFlyashRegionNameStr(region1.getFullName());
                    }
                }

            }
        }


        //减水剂

        vo.setReducer(smp.getWaterReducer());
        Integer waterReducerId = smp.getWaterReducerId();
        if (waterReducerId != null) {
            SysWaterReducer sysWaterReducer = SysWaterReducerMap.get(waterReducerId);
            if (sysWaterReducer != null) {
                vo.setReducerModel(sysWaterReducer.getModel());
                vo.setReducerSolidContent(sysWaterReducer.getSolidContent());
                vo.setReducerCementPsteFlow(sysWaterReducer.getCementPasteFlow());
                vo.setReducerReducingRate(sysWaterReducer.getReducingRate());
                vo.setReducerRegionNameStr(sysWaterReducer.getSourceName());

            }
        }


        //增效剂
        vo.setEfficiencyAgentAgent(smp.getEfficiencyAgent());
        Integer efficiencyAgentId = smp.getEfficiencyAgentId();
        if (efficiencyAgentId != null) {
            SysEfficiencyAgent efficiencyAgent = efficiencyAgentMap.get(efficiencyAgentId);
            if (efficiencyAgent != null) {
                vo.setEfficiencyAgentModel(efficiencyAgent.getModel());
                vo.setEfficiencyAgentSourceName(efficiencyAgent.getSourceName());
            }
        }


        //膨胀剂
        vo.setSwellingAgent(smp.getExpansionAgent());
        Integer swellingAgentId = smp.getExpansionAgentId();
        if (swellingAgentId != null) {
            SysSwellingagent sysSwellingagent = swellingagentMap.get(swellingAgentId);
            if (sysSwellingagent != null) {
                vo.setSwellingagentModel(sysSwellingagent.getModel());
                vo.setSwellingagentSourceName(sysSwellingagent.getSourceName());

            }
        }


        agentVOList.add(vo);
    }

    // 生成 Excel 文件并保存到本地
    String filePath2 = saveExcelToLocalSlumpV2(agentVOList, "坍落度");

    System.out.println(filePath2+"坍落度url");

    // 返回文件的 URL
    // 返回 AjaxResult，可以包含文件的 URL
    //    return AjaxResult.success("文件已生成", filePath);

    return filePath2;
}

/*----------------------------------*/
private String saveExcelToLocalSlumpV2(List<SysMechanicalPerformanceFourthVO> agentVOList, String excelName) {
    // 创建 Excel 工具类
    ExcelUtil<SysMechanicalPerformanceFourthVO> util = new ExcelUtil<>(SysMechanicalPerformanceFourthVO.class);


    UUID uuid = UUID.randomUUID();
    int hash = Math.abs(uuid.hashCode()); // 获取 hashCode 并取正数
    int sevenDigitNumber = hash % 10000; // 取模确保是7位数字以内
    String number = String.format("%07d", sevenDigitNumber); // 补0凑足7位
    // 生成一个唯一的文件名，可以包含时间戳或其他方式
    String fileName = System.currentTimeMillis() + "_" + number + ".xlsx";

    // 设置文件保存路径（这里假设文件存储在服务器的 /uploads/ 文件夹中）
    // String filePath = "C:\\Users\\Administrator\\Desktop\\测试\\excel\\" + fileName;
    String filePath = mechanicalPerformanceExcelPath + fileName;
    // 创建目录（如果不存在）
    File dir = new File(mechanicalPerformanceExcelPath);
    if (!dir.exists()) {
        boolean created = dir.mkdirs(); // 创建目录（支持多级）
        if (created) {
            System.out.println("目录已创建: " + dir.getAbsolutePath());
        } else {
            System.out.println("目录创建失败！");
        }
    }


/*        ExcelFileHistory excelFileHistory = new ExcelFileHistory();
        excelFileHistory.setFileName(excelName);
        excelFileHistory.setFilePath(filePath);
        excelFileHistory.setCreateTime(LocalDateTime.now());
        excelFileHistory.setDeleteTime(0);
        excelFileHistory.setVersion(0);
        excelFileHistory.setType(1);//坍落度
        excelFileHistory.setUserId(SecurityUtils.getUserId());
        excelFileHistoryService.save(excelFileHistory);*/


//        SysExcelAudit sysExcelAudit = new SysExcelAudit();
//
//        sysExcelAudit.setTableName(excelName);
//        sysExcelAudit.setExcelPath(filePath);
//        sysExcelAudit.setCreateTime(LocalDateTime.now());
//        sysExcelAudit.setDeleteTime(0);
//        sysExcelAudit.setVersion(0);
//        sysExcelAudit.setType(1);//坍落度
//
//        sysExcelAuditService.save(sysExcelAudit);


    try {
        // 将数据导出到本地文件
        util.exportExcelToLocal(agentVOList, filePath);
    } catch (IOException e) {
        e.printStackTrace();
        throw new RuntimeException("导出文件失败", e);
    }

    return filePath;
}


    /*----------------------------------*/
    /*------------------------------------------------------------------------------*/


    @Override
    @Transactional
    public AjaxResult updateAudit(AuditRequestDTO auditRequestDTO) {
        Integer tableName = auditRequestDTO.getTableName();
        String id = auditRequestDTO.getId();
        Integer status = auditRequestDTO.getStatus();

        LambdaQueryWrapper<SysFileAudit> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(SysFileAudit::getId, id);
        wrapper.select(SysFileAudit::getFilePath);
        SysFileAudit oneSysFileAudit = sysFileAuditService.getOne(wrapper, false);
        String filePath = oneSysFileAudit.getFilePath();


        try {
            if (status == 1) {


                SysFileAudit updateEntity = new SysFileAudit();
                updateEntity.setStatus(1); // 设置要更新的字段

                LambdaQueryWrapper<SysFileAudit> wrapper2 = new LambdaQueryWrapper<>();
                wrapper2.eq(SysFileAudit::getId, id); // 根据id匹配

                try {
                    int updatedRows = sysFileAuditMapper.update(updateEntity, wrapper2);
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }

                // 审核通过
                String targetTable;
                switch (tableName) {
                    case 1:  //水泥
                        targetTable = "sys_cement";
                        return saveSysCement(filePath, id, 1);
                    case 2: //砂
                        targetTable = "sys_sand";

                        return saveSysSand(filePath, id, 1);
                    case 3: //石
                        targetTable = "sys_stone";

                        return saveSysStone(filePath, id, 1);
                    case 4: //粉煤灰
                        targetTable = "sys_flyash";
                        return saveSysFlyash(filePath, id, 1); // 调用粉煤灰保存逻辑

                    case 5: //减水剂
                        targetTable = "sys_water_reducer";
                        return saveSysWaterReducer(filePath, id, 1);
                    case 6: //增效剂
                        targetTable = "sys_efficiency_agent";

                        return saveSysEfficiencyAgent(filePath, id, 1);
                    case 7: //力学性能
                        targetTable = "sys_mechanical_performance";

                        return saveSysMechanicalPerformance(filePath, id, 1);
                    case 8: //变形性能
                        targetTable = "sys_deformation_performance";
                        break;
                    case 9: //耐久性能
                        targetTable = "sys_durability_performance";
                        break;
                    case 10: //水
                        targetTable = "sys_water";
                        // return savewater(filePath, id, status); // 调用粉煤灰保存逻辑
                    case 11: //矿粉

                        targetTable = "sys_mineral_powder";
                        return saveSysMineralPowder(filePath, id, 1);
                    case 12: //其他参合料  石粉
                        targetTable = "sys_other_admixtures";

                        return saveSysOtherAdmixtures(filePath, id, 1);
                    case 13: //膨胀剂
                        targetTable = "sys_swellingagent";

                        return saveSysSwellingagent(filePath, id, 1);

                    case 14: //坍落度
                        targetTable = "sys_slump";

                        return saveSysSlumpPerformance(filePath, id, 1);


                    default:
                        return AjaxResult.error("无效的表名编号: " + tableName);
                }

                // 更新审核状态为成功
                updateAuditStatus(id, status);
                return AjaxResult.success("审核通过，目标表为: " + targetTable);

            } else if (status == 2) {
                // 审核不通过处理逻辑
                updateAuditStatus(id, status);
                return AjaxResult.success("审核未通过，已更新状态");
            } else {
                return AjaxResult.error("无效的审核状态: " + status);
            }

        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.error("审核处理失败: " + e.getMessage());
        }
    }


    /*石头插入校验*/
    private AjaxResult saveSysStone(String filePath, String id, Integer status) {
        ObjectMapper objectMapper = new ObjectMapper();
        List<List<String>> data;
        try {
            // 检查文件是否存在
            File jsonFile = new File(filePath);
            if (!jsonFile.exists()) {
                return AjaxResult.error("文件不存在: " + filePath);
            }

            // 解析 JSON 文件为二维数组（每一行是一条水泥记录）
            data = objectMapper.readValue(jsonFile, new com.fasterxml.jackson.core.type.TypeReference<List<List<String>>>() {
            });
        } catch (IOException e) {
            e.printStackTrace();
            return AjaxResult.error("JSON 文件解析失败: " + e.getMessage());
        }

        int successfulInserts = 0;

        // 获取所有已存在的水泥记录并存储在一个集合中
        LambdaQueryWrapper<SysStone> wrapper = new LambdaQueryWrapper<>();
        List<SysStone> list = sysStoneService.list(wrapper);
        Map<String, SysStone> sysCementMap = new HashMap<>();
        System.out.println("sysCementMap" + sysCementMap);
        for (SysStone sysCement : list) {
            String key = sysCement.getModel() + "-" + sysCement.getStoneSpecification() +
                    "-" + sysCement.getStackingDensity() + "-" + sysCement.getCompactDensity() +
                    "-" + sysCement.getBulkDensity() + "-" + sysCement.getRegionName();

            sysCementMap.put(key, sysCement);
        }
        System.out.println("sysCementMap" + sysCementMap);
        // 创建一个临时列表，用于存储要插入的数据
        List<SysStone> batchInsertList = new ArrayList<>();
        System.out.println("batchInsertList" + batchInsertList);
        // 遍历每条水泥数据
        for (List<String> record : data) {
            if (record.size() != 6) {
                System.err.println("无效数据格式: " + record);
                continue;
            }

            try {
                // 解析数据并保证两位小数
                String model = record.get(0); // 型号
                String stoneSpecification = record.get(1); // 石子规格
                BigDecimal stackingDensity = new BigDecimal(record.get(2)).setScale(2, RoundingMode.HALF_UP); // 堆积密度
                BigDecimal compactDensity = new BigDecimal(record.get(3)).setScale(2, RoundingMode.HALF_UP); // 紧密密度
                BigDecimal bulkDensity = new BigDecimal(record.get(4)).setScale(2, RoundingMode.HALF_UP); // 表观密度
                String regionName1 = record.get(5); // 来源地区

                Integer regionName = Integer.parseInt(regionName1);

                // 构造一个唯一的键（直接拼接）
                String key = model + "-" + stoneSpecification + "-" + stackingDensity + "-" + compactDensity + "-" + bulkDensity + "-" + regionName;
                System.out.println("key: " + key);
                // 判断是否存在该记录
                if (sysCementMap.containsKey(key)) {
                    System.out.println("记录已存在（字段完全相同），跳过插入: " + record);
                    continue;
                }

                // 创建 SysStone 对象并加入临时列表
                SysStone sysStone = new SysStone();
                sysStone.setModel(model);
                sysStone.setStoneSpecification(stoneSpecification);
                sysStone.setStackingDensity(stackingDensity);
                sysStone.setCompactDensity(compactDensity);
                sysStone.setBulkDensity(bulkDensity);
                sysStone.setRegionName(regionName);
                sysStone.setId(IdUtils.generateRandomNumber());

                // 转换 LocalDateTime -> Date
                LocalDateTime now = LocalDateTime.now();
                Date date = Date.from(now.atZone(ZoneId.systemDefault()).toInstant());
                sysStone.setCreateTime(date);
                batchInsertList.add(sysStone);

            } catch (Exception e) {
                e.printStackTrace();
                System.err.println("插入数据失败: " + record);
            }
        }

        // 批量插入数据
        if (!batchInsertList.isEmpty()) {
            boolean batchInsertSuccess = sysStoneService.saveBatch(batchInsertList);
            if (batchInsertSuccess) {
                successfulInserts = batchInsertList.size();
            } else {
                System.err.println("批量插入失败");
            }
        }

        // 更新审核状态
        updateAuditStatus(id, status);

        if (successfulInserts > 0) {
            return AjaxResult.success("审核通过，插入水泥数据成功，成功条数: " + successfulInserts);
        } else {
            return AjaxResult.success("审核通过，但所有数据已存在，未插入新数据");
        }
    }


    /*砂插入校验*/
    private AjaxResult saveSysSand(String filePath, String id, Integer status) {

        ObjectMapper objectMapper = new ObjectMapper();
        List<List<String>> data;
        try {
            // 检查文件是否存在
            File jsonFile = new File(filePath);
            if (!jsonFile.exists()) {
                return AjaxResult.error("文件不存在: " + filePath);
            }

            // 解析 JSON 文件为二维数组（每一行是一条水泥记录）
            data = objectMapper.readValue(jsonFile, new com.fasterxml.jackson.core.type.TypeReference<List<List<String>>>() {
            });
        } catch (IOException e) {
            e.printStackTrace();
            return AjaxResult.error("JSON 文件解析失败: " + e.getMessage());
        }

        int successfulInserts = 0;

        // 获取所有已存在的水泥记录并存储在一个集合中
        LambdaQueryWrapper<SysSand> wrapper = new LambdaQueryWrapper<>();
        List<SysSand> list = sysSandService.list(wrapper);

        // 使用一个唯一的组合键作为 Map 的 key
        Map<String, SysSand> sysCementMap = new HashMap<>();
        for (SysSand sysCement : list) {
            String key = sysCement.getType() + "-" + sysCement.getFineness() + "-" + sysCement.getBulkDensity() + "-"
                    + sysCement.getCompactDensity() + "-" + sysCement.getApparentDensity() + "-" + sysCement.getParticleSizeDistribution()
                    + "-" + sysCement.getRegionName();
            sysCementMap.put(key, sysCement);  // 使用唯一的组合键作为 map 的 key
        }

        System.out.println("sysCementMap: " + sysCementMap);

        // 创建一个临时列表，用于存储要插入的数据
        List<SysSand> batchInsertList = new ArrayList<>();

        // 遍历每条水泥数据
        for (List<String> record : data) {
            if (record.size() != 7) {
                System.err.println("无效数据格式: " + record);
                continue;
            }

            try {
                // 解析数据
                String model = record.get(0);  // 型号

                BigDecimal fineness = new BigDecimal(record.get(1));  // 细度
                BigDecimal bulkDensity = new BigDecimal(record.get(2));  // 堆积密度 (kg/m3)
                BigDecimal compactDensity = new BigDecimal(record.get(3));  // 紧密密度 (kg/m3)
                BigDecimal apparentDensity = new BigDecimal(record.get(4));  // 表观密度 (kg/m3)

                String particleSizeDistribution = record.get(5);  // 粒径分布(mm)
                int region = Integer.parseInt(record.get(6));

                // 确保所有 BigDecimal 保留两位小数
                fineness = fineness.setScale(2, RoundingMode.HALF_UP);
                bulkDensity = bulkDensity.setScale(2, RoundingMode.HALF_UP);
                compactDensity = compactDensity.setScale(2, RoundingMode.HALF_UP);
                apparentDensity = apparentDensity.setScale(2, RoundingMode.HALF_UP);

                // 构造一个唯一的键（唯一标识记录的组合字段）
                String key = model + "-" + fineness + "-" + bulkDensity + "-" + compactDensity + "-" + apparentDensity + "-"
                        + particleSizeDistribution + "-" + region;
                System.out.println("key: " + key);

                // 判断是否存在该记录
                if (sysCementMap.containsKey(key)) {
                    System.out.println("记录已存在（完全相同的记录），跳过插入: " + record);
                    continue;
                }

                // 创建 SysSand 对象并加入临时列表
                SysSand sysSand = new SysSand();
                sysSand.setType(model);
                sysSand.setFineness(fineness);
                sysSand.setBulkDensity(bulkDensity);
                sysSand.setCompactDensity(compactDensity);
                sysSand.setApparentDensity(apparentDensity);
                sysSand.setParticleSizeDistribution(particleSizeDistribution);
                sysSand.setRegionName(region);
                sysSand.setId(IdUtils.generateRandomNumber());
                batchInsertList.add(sysSand);

            } catch (Exception e) {
                e.printStackTrace();
                System.err.println("插入数据失败: " + record);
            }
        }

        // 批量插入数据
        if (!batchInsertList.isEmpty()) {
            boolean batchInsertSuccess = sysSandService.saveBatch(batchInsertList);
            if (batchInsertSuccess) {
                successfulInserts = batchInsertList.size();  // 批量插入的成功条数
            } else {
                System.err.println("批量插入失败");
            }
        }

        // 更新审核状态（无论插入成功与否）
        updateAuditStatus(id, status);

        if (successfulInserts > 0) {
            return AjaxResult.success("审核通过，插入水泥数据成功，成功条数: " + successfulInserts);
        } else {
            return AjaxResult.success("审核通过，但所有数据已存在，未插入新数据");
        }
    }





    /*力学性能数据插入校验*/
    @Transactional
    public AjaxResult  saveSysMechanicalPerformance(String filePath, String id, Integer status) {
        ObjectMapper objectMapper = new ObjectMapper();
        List<List<String>> data;
        try {
            // 检查文件是否存在
            File jsonFile = new File(filePath);
            if (!jsonFile.exists()) {
                return AjaxResult.error("文件不存在: " + filePath);
            }

            // 解析 JSON 文件为二维数组（每一行是一条水泥记录）
            data = objectMapper.readValue(jsonFile, new com.fasterxml.jackson.core.type.TypeReference<List<List<String>>>() {
            });
        } catch (IOException e) {
            e.printStackTrace();
            return AjaxResult.error("JSON 文件解析失败: " + e.getMessage());
        }


        int successfulInserts = 0;

      // 为每种原材料创建待插入列表
        List<SysCement> newCementList = new ArrayList<>();
        List<SysStone> newStoneList = new ArrayList<>();
        List<SysSand> newSandList = new ArrayList<>();
        List<SysOtherAdmixtures> newOtherAdmixturesList = new ArrayList<>();
        List<SysMineralPowder> newMineralPowderList = new ArrayList<>();
        List<SysFlyash> newFlyashList = new ArrayList<>();
        List<SysWaterReducer> newWaterReducerList = new ArrayList<>();
        List<SysEfficiencyAgent> newEfficiencyAgentList = new ArrayList<>();
        List<SysSwellingagent> newSwellingagentList = new ArrayList<>();



        // 获取水泥数据并存储在一个集合中
        LambdaQueryWrapper<SysCement> wrapper = new LambdaQueryWrapper<>();
        List<SysCement> list = sysCementService.list(wrapper);
        Map<String, SysCement> sysCementMap = new HashMap<>();

        for (SysCement sysCement : list) {
            String key = sysCement.getModel() + "-" + sysCement.getRegionName() + "-" + sysCement.getStrengthGrade() +
                    "-" + sysCement.getCaoContent() + "-" + sysCement.getSio2Content() + "-" + sysCement.getAl2o3Content() + "-" + sysCement.getCompressiveStrength28d();
            sysCementMap.put(key, sysCement);  // 使用一个唯一的组合键作为 map 的 key
        }


        // 获取所有已存在的石头记录并存储在一个集合中
        LambdaQueryWrapper<SysStone> wrapperStone = new LambdaQueryWrapper<>();
        List<SysStone> listStone = sysStoneService.list(wrapperStone);
        Map<String, SysStone> sysStonMap = new HashMap<>();
        System.out.println("sysCementMap" + sysStonMap);
        for (SysStone sysCement : listStone) {
            String keyStone = sysCement.getModel() + "-" + sysCement.getStoneSpecification() +
                    "-" + sysCement.getStackingDensity() + "-" + sysCement.getCompactDensity() +
                    "-" + sysCement.getBulkDensity() + "-" + sysCement.getRegionName();

            sysStonMap.put(keyStone, sysCement);
        }


        // 获取所有已存在的水泥记录并存储在一个集合中
        LambdaQueryWrapper<SysFlyash> wrapperFlyash = new LambdaQueryWrapper<>();
        List<SysFlyash> listFlyash = sysFlyashService.list(wrapperFlyash);
        Map<String, SysFlyash> flyashMap = new HashMap<>();

        for (SysFlyash sysCement : listFlyash) {
            String keyFlyash = sysCement.getGrade() + "-" + sysCement.getFactoryGrade() + "-" + sysCement.getFineness() +
                    "-" + sysCement.getMoistureContent() + "-" + sysCement.getActivityIndex28d() + "-" + sysCement.getRegionName();
            flyashMap.put(keyFlyash, sysCement);  // 使用一个唯一的组合键作为 map 的 key
        }


        // 获取所有已存在的砂记录并存储在一个集合中
        LambdaQueryWrapper<SysSand> wrapperSand = new LambdaQueryWrapper<>();
        List<SysSand> listSand = sysSandService.list(wrapperSand);
        // 使用一个唯一的组合键作为 Map 的 key
        Map<String, SysSand> sysSandMap = new HashMap<>();
        for (SysSand sysCement : listSand) {
            String key = sysCement.getType() + "-" + sysCement.getFineness() + "-" + sysCement.getBulkDensity() + "-"
                    + sysCement.getCompactDensity() + "-" + sysCement.getApparentDensity() + "-" + sysCement.getParticleSizeDistribution()
                    + "-" + sysCement.getRegionName();
            sysSandMap.put(key, sysCement);  // 使用唯一的组合键作为 map 的 key
        }


        // 获取所有已存在的石粉记录并存储在一个集合中
        LambdaQueryWrapper<SysOtherAdmixtures> wrapperOtherAdmixtures = new LambdaQueryWrapper<>();
        List<SysOtherAdmixtures> listOtherAdmixtures = sysOtherAdmixturesService.list(wrapperOtherAdmixtures);
        Map<String, SysOtherAdmixtures> sysOtherAdmixturesMap = new HashMap<>();
        System.out.println("sysCementMap" + sysCementMap);
        for (SysOtherAdmixtures sysCement : listOtherAdmixtures) {
            String key = sysCement.getModel() + "-" + sysCement.getFineness() +
                    "-" + sysCement.getMoistureContent() + "-" + sysCement.getActivityIndex28d() + "-" + sysCement.getRegionName();
            sysOtherAdmixturesMap.put(key, sysCement);  // 使用一个唯一的组合键作为 map 的 key
        }


        /*矿粉*/
        LambdaQueryWrapper<SysMineralPowder> wrapperMineralPowder = new LambdaQueryWrapper<>();
        List<SysMineralPowder> listMineralPowder = sysMineralPowderService.list(wrapperMineralPowder);
        Map<String, SysMineralPowder> MineralPowderMap = new HashMap<>();

        for (SysMineralPowder sysCement : listMineralPowder) {
            String key = sysCement.getModel() + "-" + sysCement.getSlagGrade() + "-" + sysCement.getFineness() +
                    "-" + sysCement.getMoistureContent() + "-" + sysCement.getActivityIndex28d() + "-" + sysCement.getRegionName();
            MineralPowderMap.put(key, sysCement);  // 使用一个唯一的组合键作为 map 的 key
        }


        //减水剂
        LambdaQueryWrapper<SysWaterReducer> wrapperWaterReducer = new LambdaQueryWrapper<>();
        List<SysWaterReducer> listWaterReducer = sysWaterReducerService.list(wrapperWaterReducer);
        Map<String, SysWaterReducer> sysWaterReducerMap = new HashMap<>();
        System.out.println("list" + list);
        for (SysWaterReducer sysCement : listWaterReducer) {
            String keyWaterReducer = sysCement.getModel() + "-" + sysCement.getSolidContent() + "-" + sysCement.getCementPasteFlow() + "-" + sysCement.getReducingRate() + "-" + sysCement.getSourceName();

            sysWaterReducerMap.put(keyWaterReducer, sysCement);  // 使用一个唯一的组合键作为 map 的 key
        }

        System.out.println("减水剂数据库字段" + sysWaterReducerMap);

        /*增效剂*/
        LambdaQueryWrapper<SysEfficiencyAgent> wrapperEfficiencyAgent = new LambdaQueryWrapper<>();
        List<SysEfficiencyAgent> listEfficiencyAgent = sysEfficiencyAgentService.list(wrapperEfficiencyAgent);
        Map<String, SysEfficiencyAgent> efficiencyAgentMap = new HashMap<>();
        System.out.println("list" + listEfficiencyAgent);
        for (SysEfficiencyAgent sysCement : listEfficiencyAgent) {
            String key = sysCement.getModel() + "-" + sysCement.getSourceName();
            efficiencyAgentMap.put(key, sysCement);  // 使用一个唯一的组合键作为 map 的 key
        }


        /*膨胀剂*/
        // 获取所有已存在的水泥记录并存储在一个集合中
        LambdaQueryWrapper<SysSwellingagent> wrapperSwellingagent = new LambdaQueryWrapper<>();
        List<SysSwellingagent> listSysSwelling = sysSwellingagentService.list(wrapperSwellingagent);
        Map<String, SysSwellingagent> SysSwellingMap = new HashMap<>();
        System.out.println("list" + listSysSwelling);
        for (SysSwellingagent sysCement : listSysSwelling) {
            String key = sysCement.getModel() + "-" + sysCement.getSourceName();
            SysSwellingMap.put(key, sysCement);  // 使用一个唯一的组合键作为 map 的 key
        }


        // 创建一个临时列表，用于存储要插入的数据
        List<SysMechanicalPerformance> batchInsertList = new ArrayList<>();

        // 遍历每条水泥数据
        for (List<String> record : data) {
//            if (record.size() != 15) {
//                System.err.println("无效数据格式: " + record);
//                continue;
//            }


            // 解析数据
            //String regiona = record.get(0);  // 地区
            int regiona = Integer.parseInt(record.get(0));//来源地区

            // String productionDate = record.get(1);  // //生产日期
            String productionDateStr = record.get(1);
            LocalDateTime productionDate = LocalDate.parse(productionDateStr, DateTimeFormatter.ofPattern("yyyy-MM-dd"))
                    .atStartOfDay();


            String strengthGrade = record.get(2);
            ;//强度等级
            BigDecimal compressive3d = new BigDecimal(record.get(3));
            ;//3天抗压强度(MPa)
            BigDecimal compressive7d = new BigDecimal(record.get(4));  //7天抗压强度(MPa)
            BigDecimal compressive28d = new BigDecimal(record.get(5));  //28天抗压强度(MPa)
            BigDecimal water = new BigDecimal(record.get(6));   //水掺量(kg/m³)

            BigDecimal cement = new BigDecimal(record.get(7));
            ;////水泥掺量(kg/m³)

            water = water.setScale(2, RoundingMode.HALF_UP);
            cement = cement.setScale(2, RoundingMode.HALF_UP);







            /*水泥*/
            // 解析数据
            String model = record.get(8);
            BigDecimal cao = new BigDecimal(record.get(9));
            BigDecimal sio2 = new BigDecimal(record.get(10));
            BigDecimal al2o3 = new BigDecimal(record.get(11));
//            BigDecimal compressive = new BigDecimal(record.get(12));
//            BigDecimal strength = new BigDecimal(record.get(13));
            BigDecimal strength = new BigDecimal(record.get(12));
            BigDecimal compressive = new BigDecimal(record.get(13));

            int region = Integer.parseInt(record.get(14));

            // 确保所有 BigDecimal 保留两位小数
            cao = cao.setScale(2, RoundingMode.HALF_UP);
            sio2 = sio2.setScale(2, RoundingMode.HALF_UP);
            al2o3 = al2o3.setScale(2, RoundingMode.HALF_UP);
            compressive = compressive.setScale(2, RoundingMode.HALF_UP);
            strength = strength.setScale(2, RoundingMode.HALF_UP);

            // 构造一个唯一的键
            String key = model + "-" + region + "-" + strength + "-" + cao + "-" + sio2 + "-" + al2o3 + "-" + compressive;

            Integer cementId;

            if (sysCementMap.containsKey(key)) {
                // 记录存在，直接拿id
//                cementId = sysCementMap.get(key).getId();
                cementId = sysCementMap.get(key).getCementId();  // 使用正确的字段名称

                System.out.println("找到已有水泥数据，id = " + cementId);
            } else {
                // 记录不存在，创建新的SysCement
                SysCement newCement = new SysCement();
                newCement.setId(IdUtils.generateRandomNumber());  // 生成id
                newCement.setModel(model);
                newCement.setRegionName(region); // 注意，regionName是字符串！
                newCement.setStrengthGrade(strength);
                newCement.setCaoContent(cao);
                newCement.setSio2Content(sio2);
                newCement.setAl2o3Content(al2o3);
                newCement.setCompressiveStrength28d(compressive);
                newCement.setCreateTime(Timestamp.valueOf(LocalDateTime.now()));

               sysCementService.save(newCement);
                //  newCementList.add(newCement);
                sysCementMap.put(key, newCement); // 插入map缓存
                cementId = newCement.getCementId();
                System.out.println("新增水泥数据，id = " + cementId);



            }
//            // 替换第8列（索引8）为水泥id
//            record.set(8, String.valueOf(cementId));
//          // 删除索引9到14的元素（一定要从大到小删）
//            for (int i = 14; i >= 9; i--) {
//                record.remove(i);
//            }


            /*-------------------------------------------------------------------------------------*/
            // String stone510 = record.get(15);// 石头5-10掺量
            BigDecimal stone510 = new BigDecimal(record.get(15));// 石头5-10掺量
            stone510 = stone510.setScale(2, RoundingMode.HALF_UP);

            /*石头5-10*/
            // 解析数据并保证两位小数
            String modelstone510 = record.get(16); // 型号
            String stoneSpecification510 = record.get(17); // 石子规格
            BigDecimal stackingDensity510 = new BigDecimal(record.get(18)).setScale(2, RoundingMode.HALF_UP); // 堆积密度
            BigDecimal compactDensity510 = new BigDecimal(record.get(19)).setScale(2, RoundingMode.HALF_UP); // 紧密密度
            BigDecimal bulkDensity510 = new BigDecimal(record.get(20)).setScale(2, RoundingMode.HALF_UP); // 表观密度
            String regionName = record.get(21); // 来源地区

            Integer regionName510 = Integer.parseInt(regionName);

            // 构造一个唯一的键（直接拼接）
            String keyModelStone510 = modelstone510 + "-" + stoneSpecification510 + "-" + stackingDensity510 + "-" + compactDensity510 + "-" + bulkDensity510 + "-" + regionName510;
            System.out.println("key: " + key);

            Integer stone510Id;
            // 判断是否存在该记录
            if (sysStonMap.containsKey(keyModelStone510)) {
                stone510Id = sysStonMap.get(keyModelStone510).getStoneId();  // 使用正确的字段名称
                System.out.println("数据库已经存在水泥数据stone510Id" + stone510Id);
            } else {
                // 创建 SysStone 对象并加入临时列表
                SysStone sysStone = new SysStone();
                sysStone.setModel(modelstone510);
                sysStone.setStoneSpecification(stoneSpecification510);
                sysStone.setStackingDensity(stackingDensity510);
                sysStone.setCompactDensity(compactDensity510);
                sysStone.setBulkDensity(bulkDensity510);
                sysStone.setRegionName(regionName510);
                sysStone.setId(IdUtils.generateRandomNumber());

              sysStoneService.save(sysStone);
                // newStoneList.add(sysStone);
                sysStonMap.put(keyModelStone510, sysStone);
                stone510Id = sysStone.getStoneId();
                System.out.println("新增石头数据，id = " + stone510Id);
            }


            /*石头石5-25mm----------------------------*/


            //String stone525 = record.get(22);// 石头5-10掺量
            BigDecimal stone525 = new BigDecimal(record.get(22));// 石头5-10掺量
            stone525 = stone525.setScale(2, RoundingMode.HALF_UP);




            /*石头5-10*/
            // 解析数据并保证两位小数
            String modelstone525 = record.get(23); // 型号
            String stoneSpecification525 = record.get(24); // 石子规格
            BigDecimal stackingDensity525 = new BigDecimal(record.get(25)).setScale(2, RoundingMode.HALF_UP); // 堆积密度
            BigDecimal compactDensity525 = new BigDecimal(record.get(26)).setScale(2, RoundingMode.HALF_UP); // 紧密密度
            BigDecimal bulkDensity525 = new BigDecimal(record.get(27)).setScale(2, RoundingMode.HALF_UP); // 表观密度
            String regionName525 = record.get(28); // 来源地区
            Integer regionName525s = Integer.parseInt(regionName525);

            // 构造一个唯一的键（直接拼接）
            String keyModelStone525 = modelstone525 + "-" + stoneSpecification525 + "-" + stackingDensity525 + "-" + compactDensity525 + "-" + bulkDensity525 + "-" + regionName525s;
            System.out.println("key: " + key);

            Integer stone525Id;
            // 判断是否存在该记录
            if (sysStonMap.containsKey(keyModelStone525)) {
                stone525Id = sysStonMap.get(keyModelStone525).getStoneId();  // 使用正确的字段名称
                System.out.println("数据库已经存在石头数据stone510Id" + stone525Id);
            } else {
                // 创建 SysStone 对象并加入临时列表
                SysStone sysStone = new SysStone();
                sysStone.setModel(modelstone525);
                sysStone.setStoneSpecification(stoneSpecification525);
                sysStone.setStackingDensity(stackingDensity525);
                sysStone.setCompactDensity(compactDensity525);
                sysStone.setBulkDensity(bulkDensity525);
                sysStone.setRegionName(regionName525s);
                sysStone.setId(IdUtils.generateRandomNumber());

                sysStoneService.save(sysStone);
                //  newStoneList.add(sysStone);
                sysStonMap.put(keyModelStone525, sysStone);
                stone525Id = sysStone.getStoneId();
                System.out.println("新增石头数据stone525，id = " + stone525Id);
            }

            /*石头石20-40mm----------------------------*/

            // String stone2040 = record.get(29);// 石头20-40掺量

            BigDecimal stone2040 = new BigDecimal(record.get(29));// 石头20-40掺量
            stone2040 = stone2040.setScale(2, RoundingMode.HALF_UP);



            /*石头5-10*/
            // 解析数据并保证两位小数
            String modelstone2040 = record.get(30); // 型号
            String stoneSpecification2040 = record.get(31); // 石子规格
            BigDecimal stackingDensity2040 = new BigDecimal(record.get(32)).setScale(2, RoundingMode.HALF_UP); // 堆积密度
            BigDecimal compactDensity2040 = new BigDecimal(record.get(33)).setScale(2, RoundingMode.HALF_UP); // 紧密密度
            BigDecimal bulkDensity2040 = new BigDecimal(record.get(34)).setScale(2, RoundingMode.HALF_UP); // 表观密度
            String regionName2040 = record.get(35); // 来源地区
            Integer regionName2040s = Integer.parseInt(regionName2040);

            // 构造一个唯一的键（直接拼接）
            String keyModelStone2040 = modelstone2040 + "-" + stoneSpecification2040 + "-" + stackingDensity2040 + "-" + compactDensity2040 + "-" + bulkDensity2040 + "-" + regionName2040s;
            System.out.println("key: " + keyModelStone2040);

            Integer stone2040Id;
            // 判断是否存在该记录
            if (sysStonMap.containsKey(keyModelStone2040)) {
                stone2040Id = sysStonMap.get(keyModelStone2040).getStoneId();  // 使用正确的字段名称
                System.out.println("数据库已经存在石头数据stone2040Id" + stone2040Id);
            } else {
                // 创建 SysStone 对象并加入临时列表
                SysStone sysStone = new SysStone();
                sysStone.setModel(modelstone2040);
                sysStone.setStoneSpecification(stoneSpecification2040);
                sysStone.setStackingDensity(stackingDensity2040);
                sysStone.setCompactDensity(compactDensity2040);
                sysStone.setBulkDensity(bulkDensity2040);
                sysStone.setRegionName(regionName2040s);
                sysStone.setId(IdUtils.generateRandomNumber());
                sysStoneService.save(sysStone);
               // newStoneList.add(sysStone);
                sysStonMap.put(keyModelStone2040, sysStone);
                stone2040Id = sysStone.getStoneId();
                System.out.println("新增石头数据stone525，id = " + stone2040Id);
            }


            /*石头20-20*/

            //  String stone1020 = record.get(36);// 石头10-50掺量

            BigDecimal stone1020 = new BigDecimal(record.get(36));// 石头5-10掺量
            stone1020 = stone1020.setScale(2, RoundingMode.HALF_UP);


            /*石头5-10*/
            // 解析数据并保证两位小数
            String modelstone1020 = record.get(37); // 型号
            String stoneSpecification1020 = record.get(38); // 石子规格
            BigDecimal stackingDensity1020 = new BigDecimal(record.get(39)).setScale(2, RoundingMode.HALF_UP); // 堆积密度
            BigDecimal compactDensity1020 = new BigDecimal(record.get(40)).setScale(2, RoundingMode.HALF_UP); // 紧密密度
            BigDecimal bulkDensity1020 = new BigDecimal(record.get(41)).setScale(2, RoundingMode.HALF_UP); // 表观密度
            String regionName1020 = record.get(42); // 来源地区
            Integer regionName1020s = Integer.parseInt(regionName1020);

            // 构造一个唯一的键（直接拼接）
            String keyModelStone1020 = modelstone1020 + "-" + stoneSpecification1020 + "-" + stackingDensity1020 + "-" + compactDensity1020 + "-" + bulkDensity1020 + "-" + regionName1020s;
            System.out.println("key: " + keyModelStone1020);

            Integer stone1020Id;
            // 判断是否存在该记录
            if (sysStonMap.containsKey(keyModelStone1020)) {
                stone1020Id = sysStonMap.get(keyModelStone1020).getStoneId();  // 使用正确的字段名称
                System.out.println("数据库已经存在石头数据stone2040Id" + stone1020Id);
            } else {
                // 创建 SysStone 对象并加入临时列表
                SysStone sysStone = new SysStone();
                sysStone.setModel(modelstone1020);
                sysStone.setStoneSpecification(stoneSpecification1020);
                sysStone.setStackingDensity(stackingDensity1020);
                sysStone.setCompactDensity(compactDensity1020);
                sysStone.setBulkDensity(bulkDensity1020);
                sysStone.setRegionName(regionName1020s);
                sysStone.setId(IdUtils.generateRandomNumber());
                sysStoneService.save(sysStone);
               // newStoneList.add(sysStone);
                sysStonMap.put(keyModelStone2040, sysStone);
                stone1020Id = sysStone.getStoneId();
                System.out.println("新增石头数据stone1020，id = " + stone1020Id);
            }

            /*石头10-30*/

            // String stone1030 = record.get(43);// 石头10-30掺量

            BigDecimal stone1030 = new BigDecimal(record.get(43));// 石头10-30掺量
            stone1030 = stone1030.setScale(2, RoundingMode.HALF_UP);


            // 解析数据并保证两位小数
            String modelstone1030 = record.get(44); // 型号
            String stoneSpecification1030 = record.get(45); // 石子规格
            BigDecimal stackingDensity1030 = new BigDecimal(record.get(46)).setScale(2, RoundingMode.HALF_UP); // 堆积密度
            BigDecimal compactDensity1030 = new BigDecimal(record.get(47)).setScale(2, RoundingMode.HALF_UP); // 紧密密度
            BigDecimal bulkDensity1030 = new BigDecimal(record.get(48)).setScale(2, RoundingMode.HALF_UP); // 表观密度
            String regionName1030 = record.get(49); // 来源地区
            Integer regionName1030s = Integer.parseInt(regionName1030);

            // 构造一个唯一的键（直接拼接）
            String keyModelStone1030 = modelstone1030 + "-" + stoneSpecification1030 + "-" + stackingDensity1030 + "-" + compactDensity1030 + "-" + bulkDensity1030 + "-" + regionName1030s;
            System.out.println("key: " + keyModelStone1030);

            Integer stone1030Id;
            // 判断是否存在该记录
            if (sysStonMap.containsKey(keyModelStone1030)) {
                stone1030Id = sysStonMap.get(keyModelStone1030).getStoneId();  // 使用正确的字段名称
                System.out.println("数据库已经存在石头数据stone2040Id" + stone1030Id);
            } else {
                // 创建 SysStone 对象并加入临时列表
                SysStone sysStone = new SysStone();
                sysStone.setModel(modelstone1030);
                sysStone.setStoneSpecification(stoneSpecification1030);
                sysStone.setStackingDensity(stackingDensity1030);
                sysStone.setCompactDensity(compactDensity1030);
                sysStone.setBulkDensity(bulkDensity1030);
                sysStone.setRegionName(regionName1030s);
                sysStone.setId(IdUtils.generateRandomNumber());
                sysStoneService.save(sysStone);
               // newStoneList.add(sysStone);
                sysStonMap.put(keyModelStone1030, sysStone);
                stone1030Id = sysStone.getStoneId();
                System.out.println("新增石头数据stone1020，id = " + stone1030Id);
            }

            /*石头0-10*/

            //String stone010 = record.get(50);// 石头0-10掺量

            BigDecimal stone010 = new BigDecimal(record.get(50));//石头0-10掺
            stone010 = stone010.setScale(2, RoundingMode.HALF_UP);


            // 解析数据并保证两位小数
            String modelstone010 = record.get(51); // 型号
            String stoneSpecification010 = record.get(52); // 石子规格
            BigDecimal stackingDensity010 = new BigDecimal(record.get(53)).setScale(2, RoundingMode.HALF_UP); // 堆积密度
            BigDecimal compactDensity010 = new BigDecimal(record.get(54)).setScale(2, RoundingMode.HALF_UP); // 紧密密度
            BigDecimal bulkDensity010 = new BigDecimal(record.get(55)).setScale(2, RoundingMode.HALF_UP); // 表观密度
            String regionName010 = record.get(56); // 来源地区
            Integer regionName010s = Integer.parseInt(regionName010);

            // 构造一个唯一的键（直接拼接）
            String keyModelStone010 = modelstone010 + "-" + stoneSpecification010 + "-" + stackingDensity010 + "-" + compactDensity010 + "-" + bulkDensity010 + "-" + regionName010s;
            System.out.println("key: " + keyModelStone1030);

            Integer stone010Id;
            // 判断是否存在该记录
            if (sysStonMap.containsKey(keyModelStone010)) {
                stone010Id = sysStonMap.get(keyModelStone010).getStoneId();  // 使用正确的字段名称
                System.out.println("数据库已经存在石头数据stone010Id" + stone010Id);
            } else {
                // 创建 SysStone 对象并加入临时列表
                SysStone sysStone = new SysStone();
                sysStone.setModel(modelstone010);
                sysStone.setStoneSpecification(stoneSpecification010);
                sysStone.setStackingDensity(stackingDensity010);
                sysStone.setCompactDensity(compactDensity010);
                sysStone.setBulkDensity(bulkDensity010);
                sysStone.setRegionName(regionName010s);
                sysStone.setId(IdUtils.generateRandomNumber());
                sysStoneService.save(sysStone);
              //  newStoneList.add(sysStone);
                sysStonMap.put(keyModelStone010, sysStone);
                stone010Id = sysStone.getStoneId();
                System.out.println("新增石头数据stone010，id = " + stone010Id);
            }




            /*石头20-315*/

            //  String stone20315 = record.get(57);// 石头20-315掺量

            BigDecimal stone20315 = new BigDecimal(record.get(57));// 石头5-10掺量
            stone20315 = stone20315.setScale(2, RoundingMode.HALF_UP);


            // 解析数据并保证两位小数
            String modelstone20315 = record.get(58); // 型号
            String stoneSpecification20315 = record.get(59); // 石子规格
            BigDecimal stackingDensity20315 = new BigDecimal(record.get(60)).setScale(2, RoundingMode.HALF_UP); // 堆积密度
            BigDecimal compactDensity20315 = new BigDecimal(record.get(61)).setScale(2, RoundingMode.HALF_UP); // 紧密密度
            BigDecimal bulkDensity20315 = new BigDecimal(record.get(62)).setScale(2, RoundingMode.HALF_UP); // 表观密度
            String regionName20315 = record.get(63); // 来源地区
            Integer regionName20315s = Integer.parseInt(regionName20315);

            // 构造一个唯一的键（直接拼接）
            String keyModelStone20315 = modelstone20315 + "-" + stoneSpecification20315 + "-" + stackingDensity20315 + "-" + compactDensity20315 + "-" + bulkDensity20315 + "-" + regionName20315s;
            System.out.println("key: " + keyModelStone20315);

            Integer stone20315Id;
            // 判断是否存在该记录
            if (sysStonMap.containsKey(keyModelStone20315)) {
                stone20315Id = sysStonMap.get(keyModelStone20315).getStoneId();  // 使用正确的字段名称
                System.out.println("数据库已经存在石头数据stone20315Id" + stone20315Id);
            } else {
                // 创建 SysStone 对象并加入临时列表
                SysStone sysStone = new SysStone();
                sysStone.setModel(modelstone20315);
                sysStone.setStoneSpecification(stoneSpecification20315);
                sysStone.setStackingDensity(stackingDensity20315);
                sysStone.setCompactDensity(compactDensity20315);
                sysStone.setBulkDensity(bulkDensity20315);
                sysStone.setRegionName(regionName20315s);
                sysStone.setId(IdUtils.generateRandomNumber());
                sysStoneService.save(sysStone);
               // newStoneList.add(sysStone);
                sysStonMap.put(keyModelStone20315, sysStone);
                stone20315Id = sysStone.getStoneId();
                System.out.println("新增石头数据stone010，id = " + stone20315Id);
            }

            /*河沙粗 31-37*/
            // String sand3137 = record.get(64);//砂3137参量

            BigDecimal sand3137 = new BigDecimal(record.get(64));// 石头5-10掺量
            sand3137 = sand3137.setScale(2, RoundingMode.HALF_UP);


            // 解析数据
            String sandModel3137 = record.get(65);  // 砂3137型号
            BigDecimal sandFineness3137 = new BigDecimal(record.get(66));  // 砂3137细度
            BigDecimal sandBulkDensity3137 = new BigDecimal(record.get(67));  // 砂3137堆积密度 (kg/m3)
            BigDecimal sandCompactDensity3137 = new BigDecimal(record.get(68));  // 砂3137紧密密度 (kg/m3)
            BigDecimal sandApparentDensity3137 = new BigDecimal(record.get(69));  // 砂3137表观密度 (kg/m3)

            String sandParticleSizeDistribution = record.get(70);  //砂3137 粒径分布(mm)
            int regionSand3137 = Integer.parseInt(record.get(71));

            // 确保所有 BigDecimal 保留两位小数
            sandFineness3137 = sandFineness3137.setScale(2, RoundingMode.HALF_UP);
            sandBulkDensity3137 = sandBulkDensity3137.setScale(2, RoundingMode.HALF_UP);
            sandCompactDensity3137 = sandCompactDensity3137.setScale(2, RoundingMode.HALF_UP);
            sandApparentDensity3137 = sandApparentDensity3137.setScale(2, RoundingMode.HALF_UP);

            // 构造一个唯一的键（唯一标识记录的组合字段）
            String keySand3137 = sandModel3137 + "-" + sandFineness3137 + "-" + sandBulkDensity3137 + "-" + sandCompactDensity3137 + "-" + sandApparentDensity3137 + "-"
                    + sandParticleSizeDistribution + "-" + regionSand3137;
            System.out.println("key: " + keySand3137);


            Integer sand3137Id;
            // 判断是否存在该记录
            if (sysSandMap.containsKey(keySand3137)) {
                sand3137Id = sysSandMap.get(keySand3137).getSandId();  // 使用正确的字段名称
                System.out.println("数据库已经存在砂数据sand3137Id" + sand3137Id);

            } else {
                // 创建 SysSand 对象并加入临时列表
                SysSand sysSand = new SysSand();
                sysSand.setType(sandModel3137);
                sysSand.setFineness(sandFineness3137);
                sysSand.setBulkDensity(sandBulkDensity3137);
                sysSand.setCompactDensity(sandCompactDensity3137);
                sysSand.setApparentDensity(sandApparentDensity3137);
                sysSand.setParticleSizeDistribution(sandParticleSizeDistribution);
                sysSand.setRegionName(regionSand3137);
                sysSand.setId(IdUtils.generateRandomNumber());

                sysSandService.save(sysSand);
               // newSandList.add(sysSand);
                sysSandMap.put(keySand3137, sysSand);
                sand3137Id = sysSand.getSandId();

                System.out.println("新增砂头数据sandId3137，id = " + sand3137Id);
            }

            /*河沙粗 23-30*/

            // String sand2330 = record.get(72);//砂3137参量
            BigDecimal sand2330 = new BigDecimal(record.get(72));// 石头5-10掺量
            sand2330 = sand2330.setScale(2, RoundingMode.HALF_UP);


            // 解析数据
            String sandModel2330 = record.get(73);  // 砂3137型号
            BigDecimal sandFineness2330 = new BigDecimal(record.get(74));  // 砂3137细度
            BigDecimal sandBulkDensity2330 = new BigDecimal(record.get(75));  // 砂3137堆积密度 (kg/m3)
            BigDecimal sandCompactDensity2330 = new BigDecimal(record.get(76));  // 砂3137紧密密度 (kg/m3)
            BigDecimal sandApparentDensity2330 = new BigDecimal(record.get(77));  // 砂3137表观密度 (kg/m3)
            String sandParticleSizeDistribution2330 = record.get(78);  //砂3137 粒径分布(mm)
            int regionSand2330 = Integer.parseInt(record.get(79));
            // 确保所有 BigDecimal 保留两位小数
            sandFineness2330 = sandFineness2330.setScale(2, RoundingMode.HALF_UP);
            sandBulkDensity2330 = sandBulkDensity2330.setScale(2, RoundingMode.HALF_UP);
            sandCompactDensity2330 = sandCompactDensity2330.setScale(2, RoundingMode.HALF_UP);
            sandApparentDensity2330 = sandApparentDensity2330.setScale(2, RoundingMode.HALF_UP);

            // 构造一个唯一的键（唯一标识记录的组合字段）
            String keySand2330 = sandModel2330 + "-" + sandFineness2330 + "-" + sandBulkDensity2330 + "-" + sandCompactDensity2330 + "-" + sandApparentDensity2330 + "-"
                    + sandParticleSizeDistribution2330 + "-" + regionSand2330;
            System.out.println("key: " + keySand2330);


            Integer sand2330Id;
            // 判断是否存在该记录
            if (sysSandMap.containsKey(keySand2330)) {
                sand2330Id = sysSandMap.get(keySand2330).getSandId();  // 使用正确的字段名称
                System.out.println("数据库已经存在砂数据sand2330Id" + sand2330Id);

            } else {
                // 创建 SysSand 对象并加入临时列表
                SysSand sysSand = new SysSand();
                sysSand.setType(sandModel2330);
                sysSand.setFineness(sandFineness2330);
                sysSand.setBulkDensity(sandBulkDensity2330);
                sysSand.setCompactDensity(sandCompactDensity2330);
                sysSand.setApparentDensity(sandApparentDensity2330);
                sysSand.setParticleSizeDistribution(sandParticleSizeDistribution2330);
                sysSand.setRegionName(regionSand2330);
                sysSand.setId(IdUtils.generateRandomNumber());
               // newSandList.add(sysSand);
                sysSandService.save(sysSand);
                sysSandMap.put(keySand2330, sysSand);
                sand2330Id = sysSand.getSandId();

                System.out.println("新增砂头数据sand2330Id，id = " + sand2330Id);
            }

            /*河砂细16-22mm*/

            // String sand1622 = record.get(80);//砂316 22参量

            BigDecimal sand1622 = new BigDecimal(record.get(80));// 石头5-10掺量
            sand1622 = sand1622.setScale(2, RoundingMode.HALF_UP);


            // 解析数据
            String sandModel1622 = record.get(81);  // 砂3137型号
            BigDecimal sandFineness1622 = new BigDecimal(record.get(82));  // 砂3137细度
            BigDecimal sandBulkDensity1622 = new BigDecimal(record.get(83));  // 砂3137堆积密度 (kg/m3)
            BigDecimal sandCompactDensity1622 = new BigDecimal(record.get(84));  // 砂3137紧密密度 (kg/m3)
            BigDecimal sandApparentDensity1622 = new BigDecimal(record.get(85));  // 砂3137表观密度 (kg/m3)
            String sandParticleSizeDistribution1622 = record.get(86);  //砂3137 粒径分布(mm)
            int regionSand1622 = Integer.parseInt(record.get(87));
            // 确保所有 BigDecimal 保留两位小数
            sandFineness1622 = sandFineness1622.setScale(2, RoundingMode.HALF_UP);
            sandBulkDensity1622 = sandBulkDensity1622.setScale(2, RoundingMode.HALF_UP);
            sandCompactDensity1622 = sandCompactDensity1622.setScale(2, RoundingMode.HALF_UP);
            sandApparentDensity1622 = sandApparentDensity1622.setScale(2, RoundingMode.HALF_UP);

            // 构造一个唯一的键（唯一标识记录的组合字段）
            String keySand1622 = sandModel1622 + "-" + sandFineness1622 + "-" + sandBulkDensity1622 + "-" + sandCompactDensity1622 + "-" + sandApparentDensity1622 + "-"
                    + sandParticleSizeDistribution1622 + "-" + regionSand1622;
            System.out.println("key: " + keySand1622);


            Integer sand1622Id;
            // 判断是否存在该记录
            if (sysSandMap.containsKey(keySand1622)) {
                sand1622Id = sysSandMap.get(keySand1622).getSandId();  // 使用正确的字段名称
                System.out.println("数据库已经存在砂数据sand1622Id" + sand1622Id);

            } else {
                // 创建 SysSand 对象并加入临时列表
                SysSand sysSand = new SysSand();
                sysSand.setType(sandModel1622);
                sysSand.setFineness(sandFineness1622);
                sysSand.setBulkDensity(sandBulkDensity1622);
                sysSand.setCompactDensity(sandCompactDensity1622);
                sysSand.setApparentDensity(sandApparentDensity1622);
                sysSand.setParticleSizeDistribution(sandParticleSizeDistribution1622);
                sysSand.setRegionName(regionSand2330);
                sysSand.setId(IdUtils.generateRandomNumber());

                sysSandService.save(sysSand);
               // newSandList.add(sysSand);
                sysSandMap.put(keySand1622, sysSand);
                sand1622Id = sysSand.getSandId();

                System.out.println("新增砂头数据sand1622Id，id = " + sand1622Id);
            }
            /*机制砂中23-30Bmm*/
            //  String sand2330B = record.get(88);//砂3137参量
            BigDecimal sand2330B = new BigDecimal(record.get(88));// 机制砂中23-30B
            sand2330B = sand2330B.setScale(2, RoundingMode.HALF_UP);


            // 解析数据
            String sandModel2330B = record.get(89);  // 砂3137型号
            BigDecimal sandFineness2330B = new BigDecimal(record.get(90));  // 砂3137细度
            BigDecimal sandBulkDensity2330B = new BigDecimal(record.get(91));  // 砂3137堆积密度 (kg/m3)
            BigDecimal sandCompactDensity2330B = new BigDecimal(record.get(92));  // 砂3137紧密密度 (kg/m3)
            BigDecimal sandApparentDensity2330B = new BigDecimal(record.get(93));  // 砂3137表观密度 (kg/m3)
            String sandParticleSizeDistribution2330B = record.get(94);  //砂3137 粒径分布(mm)
            int regionSand2330B = Integer.parseInt(record.get(95));
            // 确保所有 BigDecimal 保留两位小数
            sandFineness2330B = sandFineness2330B.setScale(2, RoundingMode.HALF_UP);
            sandBulkDensity2330B = sandBulkDensity2330B.setScale(2, RoundingMode.HALF_UP);
            sandCompactDensity2330B = sandCompactDensity2330B.setScale(2, RoundingMode.HALF_UP);
            sandApparentDensity2330B = sandApparentDensity2330B.setScale(2, RoundingMode.HALF_UP);

            // 构造一个唯一的键（唯一标识记录的组合字段）
            String keySand2330B = sandModel2330B + "-" + sandFineness2330B + "-" + sandBulkDensity2330B + "-" + sandCompactDensity2330B + "-" + sandApparentDensity2330B + "-"
                    + sandParticleSizeDistribution2330B + "-" + regionSand2330B;
            System.out.println("key: " + keySand2330B);


            Integer sand2330BId;
            // 判断是否存在该记录
            if (sysSandMap.containsKey(keySand2330B)) {
                sand2330BId = sysSandMap.get(keySand2330B).getSandId();  // 使用正确的字段名称
                System.out.println("数据库已经存在砂数据sand1622Id" + sand2330BId);

            } else {
                // 创建 SysSand 对象并加入临时列表
                SysSand sysSand = new SysSand();
                sysSand.setType(sandModel2330B);
                sysSand.setFineness(sandFineness2330B);
                sysSand.setBulkDensity(sandBulkDensity2330B);
                sysSand.setCompactDensity(sandCompactDensity2330B);
                sysSand.setApparentDensity(sandApparentDensity2330B);
                sysSand.setParticleSizeDistribution(sandParticleSizeDistribution2330B);
                sysSand.setRegionName(regionSand2330B);
                sysSand.setId(IdUtils.generateRandomNumber());

                sysSandService.save(sysSand);
              //  newSandList.add(sysSand);
                sysSandMap.put(keySand2330B, sysSand);
                sand2330BId = sysSand.getSandId();
                System.out.println("新增砂头数据sand1622Id，id = " + sand2330BId);
            }


            /*机制粗中31-37Bmm*/
            // String sand3137B = record.get(96);//砂3137参量

            BigDecimal sand3137B = new BigDecimal(record.get(96));// 石头5-10掺量
            sand3137B = sand3137B.setScale(2, RoundingMode.HALF_UP);


            // 解析数据
            String sandModel3137B = record.get(97);  // 砂3137型号
            BigDecimal sandFineness3137B = new BigDecimal(record.get(98));  // 砂3137细度
            BigDecimal sandBulkDensity3137B = new BigDecimal(record.get(99));  // 砂3137堆积密度 (kg/m3)
            BigDecimal sandCompactDensity3137B = new BigDecimal(record.get(100));  // 砂3137紧密密度 (kg/m3)
            BigDecimal sandApparentDensity3137B = new BigDecimal(record.get(101));  // 砂3137表观密度 (kg/m3)
            String sandParticleSizeDistribution3137B = record.get(102);  //砂3137 粒径分布(mm)
            int regionSand3137B = Integer.parseInt(record.get(103));
            // 确保所有 BigDecimal 保留两位小数
            sandFineness3137B = sandFineness3137B.setScale(2, RoundingMode.HALF_UP);
            sandBulkDensity3137B = sandBulkDensity3137B.setScale(2, RoundingMode.HALF_UP);
            sandCompactDensity3137B = sandCompactDensity3137B.setScale(2, RoundingMode.HALF_UP);
            sandApparentDensity3137B = sandApparentDensity3137B.setScale(2, RoundingMode.HALF_UP);

            // 构造一个唯一的键（唯一标识记录的组合字段）
            String keySand3137B = sandModel3137B + "-" + sandFineness3137B + "-" + sandBulkDensity3137B + "-" + sandCompactDensity3137B + "-" + sandApparentDensity3137B + "-"
                    + sandParticleSizeDistribution3137B + "-" + regionSand3137B;
            System.out.println("key: " + keySand2330B);


            Integer sand3137BId;
            // 判断是否存在该记录
            if (sysSandMap.containsKey(keySand3137B)) {
                sand3137BId = sysSandMap.get(keySand3137B).getSandId();  // 使用正确的字段名称
                System.out.println("数据库已经存在砂数据sand1622Id" + sand3137BId);

            } else {
                // 创建 SysSand 对象并加入临时列表
                SysSand sysSand = new SysSand();
                sysSand.setType(sandModel3137B);
                sysSand.setFineness(sandFineness3137B);
                sysSand.setBulkDensity(sandBulkDensity3137B);
                sysSand.setCompactDensity(sandCompactDensity3137B);
                sysSand.setApparentDensity(sandApparentDensity3137B);
                sysSand.setParticleSizeDistribution(sandParticleSizeDistribution3137B);
                sysSand.setRegionName(regionSand3137B);
                sysSand.setId(IdUtils.generateRandomNumber());

              sysSandService.save(sysSand);
                //newSandList.add(sysSand);
                sysSandMap.put(keySand3137B, sysSand);
                sand3137BId = sysSand.getSandId();
                System.out.println("新增砂头数据sand1622Id，id = " + sand3137BId);
            }

            /*机制砂细16-22Bmm*/
            // String sand1622B = record.get(104);//砂3137参量

            BigDecimal sand1622B = new BigDecimal(record.get(104));// 石头5-10掺量
            sand1622B = sand1622B.setScale(2, RoundingMode.HALF_UP);


            // 解析数据
            String sandModel1622B = record.get(105);  // 砂3137型号
            BigDecimal sandFineness1622B = new BigDecimal(record.get(106));  // 砂3137细度
            BigDecimal sandBulkDensity1622B = new BigDecimal(record.get(107));  // 砂3137堆积密度 (kg/m3)
            BigDecimal sandCompactDensity1622B = new BigDecimal(record.get(108));  // 砂3137紧密密度 (kg/m3)
            BigDecimal sandApparentDensity1622B = new BigDecimal(record.get(109));  // 砂3137表观密度 (kg/m3)
            String sandParticleSizeDistribution1622B = record.get(110);  //砂3137 粒径分布(mm)
            int regionSand1622B = Integer.parseInt(record.get(111));
            // 确保所有 BigDecimal 保留两位小数
            sandFineness1622B = sandFineness1622B.setScale(2, RoundingMode.HALF_UP);
            sandBulkDensity1622B = sandBulkDensity1622B.setScale(2, RoundingMode.HALF_UP);
            sandCompactDensity1622B = sandCompactDensity1622B.setScale(2, RoundingMode.HALF_UP);
            sandApparentDensity1622B = sandApparentDensity1622B.setScale(2, RoundingMode.HALF_UP);

            // 构造一个唯一的键（唯一标识记录的组合字段）
            String keySand1622B = sandModel1622B + "-" + sandFineness1622B + "-" + sandBulkDensity1622B + "-" + sandCompactDensity1622B + "-" + sandApparentDensity1622B + "-"
                    + sandParticleSizeDistribution1622B + "-" + regionSand1622B;
            System.out.println("key: " + keySand2330B);


            Integer sand1622BId;
            // 判断是否存在该记录
            if (sysSandMap.containsKey(keySand1622B)) {
                sand1622BId = sysSandMap.get(keySand1622B).getSandId();  // 使用正确的字段名称
                System.out.println("数据库已经存在砂数据sand1622Id" + sand1622BId);

            } else {
                // 创建 SysSand 对象并加入临时列表
                SysSand sysSand = new SysSand();
                sysSand.setType(sandModel1622B);
                sysSand.setFineness(sandFineness1622B);
                sysSand.setBulkDensity(sandBulkDensity1622B);
                sysSand.setCompactDensity(sandCompactDensity1622B);
                sysSand.setApparentDensity(sandApparentDensity1622B);
                sysSand.setParticleSizeDistribution(sandParticleSizeDistribution1622B);
                sysSand.setRegionName(regionSand1622B);
                sysSand.setId(IdUtils.generateRandomNumber());

                sysSandService.save(sysSand);
                newSandList.add(sysSand);
                sysSandMap.put(keySand1622B, sysSand);
                sand1622BId = sysSand.getSandId();
                System.out.println("新增砂头数据sand1622Id，id = " + sand1622BId);
            }


            /*砂0475*/
            // String sand0475 = record.get(112);//砂3137参量

            BigDecimal sand0475 = new BigDecimal(record.get(112));// 石头5-10掺量
            sand0475 = sand0475.setScale(2, RoundingMode.HALF_UP);


            // 解析数据
            String sandModel0475 = record.get(113);  // 砂3137型号
            BigDecimal sandFineness0475 = new BigDecimal(record.get(114));  // 砂3137细度
            BigDecimal sandBulkDensity0475 = new BigDecimal(record.get(115));  // 砂3137堆积密度 (kg/m3)
            BigDecimal sandCompactDensity0475 = new BigDecimal(record.get(116));  // 砂3137紧密密度 (kg/m3)
            BigDecimal sandApparentDensity0475 = new BigDecimal(record.get(117));  // 砂3137表观密度 (kg/m3)
            String sandParticleSizeDistribution0475 = record.get(118);  //砂3137 粒径分布(mm)
            int regionSand0475 = Integer.parseInt(record.get(119));
            // 确保所有 BigDecimal 保留两位小数
            sandFineness0475 = sandFineness0475.setScale(2, RoundingMode.HALF_UP);
            sandBulkDensity0475 = sandBulkDensity0475.setScale(2, RoundingMode.HALF_UP);
            sandCompactDensity0475 = sandCompactDensity0475.setScale(2, RoundingMode.HALF_UP);
            sandApparentDensity0475 = sandApparentDensity0475.setScale(2, RoundingMode.HALF_UP);

            // 构造一个唯一的键（唯一标识记录的组合字段）
            String keySand0475 = sandModel0475 + "-" + sandFineness0475 + "-" + sandBulkDensity0475 + "-" + sandCompactDensity0475 + "-" + sandApparentDensity0475 + "-"
                    + sandParticleSizeDistribution0475 + "-" + regionSand0475;
            System.out.println("key: " + keySand2330B);


            Integer sand0475Id;
            // 判断是否存在该记录
            if (sysSandMap.containsKey(keySand0475)) {
                sand0475Id = sysSandMap.get(keySand0475).getSandId();  // 使用正确的字段名称
                System.out.println("数据库已经存在砂数据sand1622Id" + sand0475Id);

            } else {
                // 创建 SysSand 对象并加入临时列表
                SysSand sysSand = new SysSand();
                sysSand.setType(sandModel0475);
                sysSand.setFineness(sandFineness0475);
                sysSand.setBulkDensity(sandBulkDensity0475);
                sysSand.setCompactDensity(sandCompactDensity0475);
                sysSand.setApparentDensity(sandApparentDensity0475);
                sysSand.setParticleSizeDistribution(sandParticleSizeDistribution0475);
                sysSand.setRegionName(regionSand0475);
                sysSand.setId(IdUtils.generateRandomNumber());

                sysSandService.save(sysSand);
                sysSandMap.put(keySand0475, sysSand);
                sand0475Id = sysSand.getSandId();
                System.out.println("新增砂头数据sand1622Id，id = " + sand0475Id);
            }

            /*砂09*/
            //String sand09 = record.get(120);//砂3137参量

            BigDecimal sand09 = new BigDecimal(record.get(120));// 石头5-10掺量
            sand09 = sand09.setScale(2, RoundingMode.HALF_UP);


            // 解析数据
            String sandModel09 = record.get(121);  // 砂3137型号
            BigDecimal sandFineness09 = new BigDecimal(record.get(122));  // 砂3137细度
            BigDecimal sandBulkDensity09 = new BigDecimal(record.get(123));  // 砂3137堆积密度 (kg/m3)
            BigDecimal sandCompactDensity09 = new BigDecimal(record.get(124));  // 砂3137紧密密度 (kg/m3)
            BigDecimal sandApparentDensity09 = new BigDecimal(record.get(125));  // 砂3137表观密度 (kg/m3)
            String sandParticleSizeDistribution09 = record.get(126);  //砂3137 粒径分布(mm)
            int regionSand09 = Integer.parseInt(record.get(127));
            // 确保所有 BigDecimal 保留两位小数
            sandFineness09 = sandFineness09.setScale(2, RoundingMode.HALF_UP);
            sandBulkDensity09 = sandBulkDensity09.setScale(2, RoundingMode.HALF_UP);
            sandCompactDensity09 = sandCompactDensity09.setScale(2, RoundingMode.HALF_UP);
            sandApparentDensity09 = sandApparentDensity09.setScale(2, RoundingMode.HALF_UP);

            // 构造一个唯一的键（唯一标识记录的组合字段）
            String keySand09 = sandModel09 + "-" + sandFineness09 + "-" + sandBulkDensity09 + "-" + sandCompactDensity09 + "-" + sandApparentDensity09 + "-"
                    + sandParticleSizeDistribution09 + "-" + regionSand09;
            System.out.println("key: " + keySand09);


            Integer sand09Id;
            // 判断是否存在该记录
            if (sysSandMap.containsKey(keySand09)) {
                sand09Id = sysSandMap.get(keySand09).getSandId();  // 使用正确的字段名称
                System.out.println("数据库已经存在砂数据sand1622Id" + sand09Id);

            } else {
                // 创建 SysSand 对象并加入临时列表
                SysSand sysSand = new SysSand();
                sysSand.setType(sandModel09);
                sysSand.setFineness(sandFineness09);
                sysSand.setBulkDensity(sandBulkDensity09);
                sysSand.setCompactDensity(sandCompactDensity09);
                sysSand.setApparentDensity(sandApparentDensity09);
                sysSand.setParticleSizeDistribution(sandParticleSizeDistribution09);
                sysSand.setRegionName(regionSand09);
                sysSand.setId(IdUtils.generateRandomNumber());

                sysSandService.save(sysSand);
                sysSandMap.put(keySand09, sysSand);
                sand09Id = sysSand.getSandId();
                System.out.println("新增砂头数据sand1622Id，id = " + sand09Id);
            }

            /* 石粉*/

            // String otherAdmixturesStonePowder = record.get(128);//石粉用量
            BigDecimal otherAdmixturesStonePowder = new BigDecimal(record.get(128));// 石头5-10掺量
            otherAdmixturesStonePowder = otherAdmixturesStonePowder.setScale(2, RoundingMode.HALF_UP);


            // 解析数据
            String otherAdmixturesModel = record.get(129);//型号

            BigDecimal otherAdmixturesFineness = new BigDecimal(record.get(130));//细度
            BigDecimal otherAdmixturesMoistureContent = new BigDecimal(record.get(131));//含水量
            BigDecimal otherAdmixturesActivityIndex28d = new BigDecimal(record.get(132));//28天活性指数(%)

            int otherAdmixturesRegionName = Integer.parseInt(record.get(133));//来源地区

            // 确保所有 BigDecimal 保留两位小数
            otherAdmixturesFineness = otherAdmixturesFineness.setScale(2, RoundingMode.HALF_UP);
            otherAdmixturesMoistureContent = otherAdmixturesMoistureContent.setScale(2, RoundingMode.HALF_UP);
            otherAdmixturesActivityIndex28d = otherAdmixturesActivityIndex28d.setScale(2, RoundingMode.HALF_UP);

            // 构造一个唯一的键
            String otherAdmixturesKey = otherAdmixturesModel + "-" + otherAdmixturesFineness + "-" + otherAdmixturesMoistureContent + "-" + otherAdmixturesActivityIndex28d + "-" + otherAdmixturesRegionName;
            System.out.println("key" + otherAdmixturesKey);


            Integer otherAdmixturesId;
            // 判断是否存在该记录
            if (sysOtherAdmixturesMap.containsKey(otherAdmixturesKey)) {
                otherAdmixturesId = sysOtherAdmixturesMap.get(otherAdmixturesKey).getAdmixturesId();  // 使用正确的字段名称
                System.out.println("数据库已经存在砂数据otherAdmixturesId" + otherAdmixturesId);
            } else {


                SysOtherAdmixtures sysOtherAdmixtures = new SysOtherAdmixtures();
                sysOtherAdmixtures.setModel(otherAdmixturesModel);
                sysOtherAdmixtures.setFineness(otherAdmixturesFineness);
                sysOtherAdmixtures.setMoistureContent(otherAdmixturesMoistureContent);
                sysOtherAdmixtures.setActivityIndex28d(otherAdmixturesActivityIndex28d);
                sysOtherAdmixtures.setRegionName(otherAdmixturesRegionName);
                sysOtherAdmixtures.setCreateTime(Timestamp.valueOf(LocalDateTime.now()));
                sysOtherAdmixtures.setId(IdUtils.generateRandomNumber());

                sysOtherAdmixturesService.save(sysOtherAdmixtures);
                sysOtherAdmixturesMap.put(otherAdmixturesKey, sysOtherAdmixtures);

                otherAdmixturesId = sysOtherAdmixtures.getAdmixturesId();
                System.out.println("新增砂头数据otherAdmixturesId，id = " + otherAdmixturesId);
            }

            /*矿粉*/
            //  String mineralPowder = record.get(134);//矿粉掺量
            BigDecimal mineralPowder = new BigDecimal(record.get(134));// 石头5-10掺量
            mineralPowder = mineralPowder.setScale(2, RoundingMode.HALF_UP);


            String mineralPowderModel = record.get(135);//矿粉型号
            String mineralPowderSlagGrade = record.get(136);//矿粉等级

            BigDecimal mineralPowderFineness = new BigDecimal(record.get(137));//细度(%)
            BigDecimal mineralPowderMoistureContent = new BigDecimal(record.get(138));//含水量
            BigDecimal mineralPowderActivityIndex28d = new BigDecimal(record.get(139));//28天活性指数(%)
            int mineralPowderRegionName = Integer.parseInt(record.get(140));//来源地区

            // 确保所有 BigDecimal 保留两位小数
            mineralPowderFineness = mineralPowderFineness.setScale(2, RoundingMode.HALF_UP);
            mineralPowderMoistureContent = mineralPowderMoistureContent.setScale(2, RoundingMode.HALF_UP);
            mineralPowderActivityIndex28d = mineralPowderActivityIndex28d.setScale(2, RoundingMode.HALF_UP);

            String keyMineralPowder = mineralPowderModel + "-" + mineralPowderSlagGrade + "-" + mineralPowderFineness + "-" + mineralPowderMoistureContent + "-" + mineralPowderActivityIndex28d + "-" + mineralPowderRegionName;
            Integer mineralPowderId;
            // 判断是否存在该记录
            if (MineralPowderMap.containsKey(keyMineralPowder)) {
                mineralPowderId = MineralPowderMap.get(keyMineralPowder).getPowderId();  // 使用正确的字段名称
                System.out.println("数据库已经存在矿粉数据mineralPowderId" + mineralPowderId);
            } else {

                SysMineralPowder powder = new SysMineralPowder();
                powder.setModel(mineralPowderModel);
                powder.setSlagGrade(mineralPowderSlagGrade);
                powder.setFineness(mineralPowderFineness);
                powder.setMoistureContent(mineralPowderMoistureContent);
                powder.setActivityIndex28d(mineralPowderActivityIndex28d);
                powder.setRegionName(mineralPowderRegionName);
                powder.setCreateTime(Timestamp.valueOf(LocalDateTime.now()));
                powder.setId(IdUtils.generateRandomNumber());

                sysMineralPowderService.save(powder);
                MineralPowderMap.put(otherAdmixturesKey, powder);

                mineralPowderId = powder.getPowderId();

                System.out.println("新增矿粉数据mineralPowderId，id = " + mineralPowderId);
            }

            /*粉煤灰*/
            //String flyash = record.get(141);//粉煤灰掺量

            BigDecimal flyash = new BigDecimal(record.get(141));// 石头5-10掺量
            flyash = flyash.setScale(2, RoundingMode.HALF_UP);


            String flyashModel = record.get(142);//粉煤灰型号
            String flyashfactoryGrade = record.get(143);//粉煤灰出厂等级

            BigDecimal flyashFineness = new BigDecimal(record.get(144));//粉煤灰细度(%)
            BigDecimal flyashMoistureContent = new BigDecimal(record.get(145));//粉煤灰含水量
            BigDecimal flyashActivityIndex28d = new BigDecimal(record.get(146));//粉煤灰28天活性指数(%)
            int flyashRegionName = Integer.parseInt(record.get(147));//粉煤灰来源地区

            // 确保所有 BigDecimal 保留两位小数
            flyashFineness = flyashFineness.setScale(2, RoundingMode.HALF_UP);
            flyashMoistureContent = flyashMoistureContent.setScale(2, RoundingMode.HALF_UP);
            flyashActivityIndex28d = flyashActivityIndex28d.setScale(2, RoundingMode.HALF_UP);
            // 构造一个唯一的键
            String keyFlyash = flyashModel + "-" + flyashfactoryGrade + "-" + flyashFineness + "-" + flyashMoistureContent + "-" + flyashActivityIndex28d + "-" + flyashRegionName;


            Integer flyashId;
            // 判断是否存在该记录
            if (flyashMap.containsKey(keyFlyash)) {
                flyashId = flyashMap.get(keyFlyash).getFlyashId();
                System.out.println("数据库已经存在矿粉数据flyashId" + flyashId);
            } else {

                SysFlyash sysFlyash = new SysFlyash();
                sysFlyash.setGrade(flyashModel);
                sysFlyash.setFactoryGrade(flyashfactoryGrade);
                sysFlyash.setFineness(flyashFineness);
                sysFlyash.setMoistureContent(flyashMoistureContent);
                sysFlyash.setActivityIndex28d(flyashActivityIndex28d);
                sysFlyash.setRegionName(flyashRegionName);
                sysFlyash.setCreateTime(Timestamp.valueOf(LocalDateTime.now()));
                sysFlyash.setId(IdUtils.generateRandomNumber());
                sysFlyashService.save(sysFlyash);

                flyashMap.put(keyFlyash, sysFlyash);
                flyashId = sysFlyash.getFlyashId();

                System.out.println("新增矿粉数据flyashId，id = " + flyashId);
            }


            /*减水剂*/

            // String waterReducer = record.get(148);//减水剂参量
            BigDecimal waterReducer = new BigDecimal(record.get(148));// 石头5-10掺量
            waterReducer = waterReducer.setScale(2, RoundingMode.HALF_UP);


            String WaterReducermodel = record.get(149);//减水剂型号

            BigDecimal WaterReducersolidContent = new BigDecimal(record.get(150));//含固量(%)
            BigDecimal WaterReducercementPasteFlow = new BigDecimal(record.get(151));//水泥净浆流动度(mm)
            BigDecimal WaterReducerreducingRate = new BigDecimal(record.get(152));//减水率

            String WaterReducerRegionName = record.get(153);//来源地区

            // 确保所有 BigDecimal 保留两位小数
            WaterReducersolidContent = WaterReducersolidContent.setScale(2, RoundingMode.HALF_UP);
            WaterReducercementPasteFlow = WaterReducercementPasteFlow.setScale(2, RoundingMode.HALF_UP);
            WaterReducerreducingRate = WaterReducerreducingRate.setScale(2, RoundingMode.HALF_UP);
            // 构造一个唯一的键
            String keyWaterReducer = WaterReducermodel + "-" + WaterReducersolidContent + "-" + WaterReducercementPasteFlow + "-" + WaterReducerreducingRate + "-" + WaterReducerRegionName;
            System.out.println("减水剂插入数据" + keyWaterReducer);
            Integer waterReducerId;
            if (sysWaterReducerMap.containsKey(keyWaterReducer)) {
                waterReducerId = sysWaterReducerMap.get(keyWaterReducer).getReducerId();
                System.out.println("减水剂 记录已存在（字段完全相同），跳过插入: " + waterReducerId);
            } else {

                SysWaterReducer sysWaterReducer = new SysWaterReducer();
                sysWaterReducer.setModel(WaterReducermodel);
                sysWaterReducer.setSolidContent(WaterReducersolidContent);
                sysWaterReducer.setCementPasteFlow(WaterReducercementPasteFlow);
                sysWaterReducer.setReducingRate(WaterReducerreducingRate);
                sysWaterReducer.setSourceName(WaterReducerRegionName);

                sysWaterReducer.setCreateTime(Timestamp.valueOf(LocalDateTime.now()));
                sysWaterReducer.setId(IdUtils.generateRandomNumber());
                sysWaterReducerService.save(sysWaterReducer);

                sysWaterReducerMap.put(keyWaterReducer, sysWaterReducer);

                waterReducerId = sysWaterReducer.getReducerId();


                System.out.println("新增减水剂数据reducerId，id = " + waterReducerId);
            }

            /*增效剂*/
            //  String efficiencyAgent = record.get(154);//增效剂掺量

            BigDecimal efficiencyAgent = new BigDecimal(record.get(154));// 石头5-10掺量
            efficiencyAgent = efficiencyAgent.setScale(2, RoundingMode.HALF_UP);


            String efficiencyAgentModel = record.get(155);//增效剂型号
            String efficiencyAgentRegionName = record.get(156);//增效剂来源

            String efficiencyAgentKey = efficiencyAgentModel + "-" + efficiencyAgentRegionName;
            Integer efficiencyAgentId;
            if (efficiencyAgentMap.containsKey(efficiencyAgentKey)) {
                efficiencyAgentId = efficiencyAgentMap.get(efficiencyAgentKey).getAgentId();
                System.out.println("记录已存在（字段完全相同），跳过插入: " + efficiencyAgentId);
            } else {
                SysEfficiencyAgent sysEfficiencyAgent = new SysEfficiencyAgent();
                sysEfficiencyAgent.setModel(efficiencyAgentModel);
                sysEfficiencyAgent.setSourceName(efficiencyAgentRegionName);
                sysEfficiencyAgent.setCreateTime(Timestamp.valueOf(LocalDateTime.now()));
                sysEfficiencyAgent.setDeleteTime(0);
                sysEfficiencyAgent.setId(IdUtils.generateRandomNumber());

                sysEfficiencyAgentService.save(sysEfficiencyAgent);

                efficiencyAgentMap.put(efficiencyAgentKey, sysEfficiencyAgent);
                efficiencyAgentId = sysEfficiencyAgent.getAgentId();


                System.out.println("新增增效剂数据efficiencyAgentId，id = " + efficiencyAgentId);
            }


            // String swellinAagent = record.get(157);//膨胀剂掺量型号
            BigDecimal swellinAagent = new BigDecimal(record.get(157));// 石头5-10掺量
            swellinAagent = swellinAagent.setScale(2, RoundingMode.HALF_UP);


            String swellingAgentmodel = record.get(158);//型号
            String swellingAgentRegionName = record.get(159);//来源地区


            // 构造一个唯一的键
            String keySwellingagent = swellingAgentmodel + "-" + swellingAgentRegionName;
            System.out.println("哈哈哈key" + key);
            // 判断是否存在该记录

            Integer sysSwellingId;
            if (SysSwellingMap.containsKey(keySwellingagent)) {
                sysSwellingId = SysSwellingMap.get(keySwellingagent).getSwellingagentId();
                System.out.println("记录已存在（字段完全相同），跳过插入: " + sysSwellingId);
            } else {
                SysSwellingagent sysSwellingagent = new SysSwellingagent();
                sysSwellingagent.setModel(swellingAgentmodel);
                sysSwellingagent.setSourceName(swellingAgentRegionName);
                sysSwellingagent.setCreateTime(Timestamp.valueOf(LocalDateTime.now()));
                sysSwellingagent.setDeleteTime(0);
                sysSwellingagent.setId(IdUtils.generateRandomNumber());

                sysSwellingagentService.save(sysSwellingagent);
                SysSwellingMap.put(keySwellingagent, sysSwellingagent);
                sysSwellingId = sysSwellingagent.getSwellingagentId();

                System.out.println("新增膨胀剂数据sysSwellingId，id = " + sysSwellingId);
            }


            SysMechanicalPerformance sysMechanicalPerformance = new SysMechanicalPerformance();
            sysMechanicalPerformance.setCementId(cementId);//1
            sysMechanicalPerformance.setStone510Id(stone510Id);//2
            sysMechanicalPerformance.setStone525Id(stone525Id);//3
            sysMechanicalPerformance.setStone2040Id(stone2040Id);//4
            sysMechanicalPerformance.setStone1020Id(stone1020Id);//5
            sysMechanicalPerformance.setStone1030Id(stone1030Id);//6
            sysMechanicalPerformance.setStone010Id(stone010Id);//7
            sysMechanicalPerformance.setStone2031Id(stone20315Id);//8
            sysMechanicalPerformance.setSandRiverCoarse3137Id(sand3137Id);//9
            sysMechanicalPerformance.setSandRiver2330MedId(sand2330Id);//10
            sysMechanicalPerformance.setSandRiver1622FineId(sand1622Id);//11
            sysMechanicalPerformance.setSandMech2330MedId(sand2330BId);//12
            sysMechanicalPerformance.setSandMech3137CoarseId(sand3137BId);//13
            sysMechanicalPerformance.setSandMech1622FineId(sand1622BId);//14
            sysMechanicalPerformance.setSandMech0475Id(sand0475Id);//15
            sysMechanicalPerformance.setSandMech09Id(sand09Id);//16
            sysMechanicalPerformance.setStonePowderId(otherAdmixturesId);//17
            sysMechanicalPerformance.setMineralPowderId(mineralPowderId);//18
            sysMechanicalPerformance.setFlyAshId(flyashId);//19
            sysMechanicalPerformance.setWaterReducerId(waterReducerId);//20
            sysMechanicalPerformance.setEfficiencyAgentId(efficiencyAgentId);//21
            sysMechanicalPerformance.setExpansionAgentId(sysSwellingId);//22


            batchInsertList.add(sysMechanicalPerformance);//


            //插入力学性能
            // 获取所有已存在的力学性能数据
            LambdaQueryWrapper<SysMechanicalPerformance> wrapperSysMechanicalPerformance = new LambdaQueryWrapper<>();
            List<SysMechanicalPerformance> listwrapperSysMechanicalPerformance = sysMechanicalPerformanceService.list(wrapperSysMechanicalPerformance);

            Map<String, SysMechanicalPerformance> wrapperSysMechanicalPerformanceMap = new HashMap<>();
            // 将数据库中的所有数据按唯一组合键存入 Map
            for (SysMechanicalPerformance sysCement : listwrapperSysMechanicalPerformance) {
                String keySysMechanicalPerformance =
                        sysCement.getCementId() + "-" +
                                sysCement.getStone510Id() + "-" +
                                sysCement.getStone525Id() + "-" +
                                sysCement.getStone2040Id() + "-" +
                                sysCement.getStone1020Id() + "-" +
                                sysCement.getStone1030Id() + "-" +
                                sysCement.getStone010Id() + "-" +
                                sysCement.getStone2031Id() + "-" +
                                sysCement.getSandRiverCoarse3137Id() + "-" +
                                sysCement.getSandRiver2330MedId() + "-" +
                                sysCement.getSandRiver1622FineId() + "-" +
                                sysCement.getSandMech2330MedId() + "-" +
                                sysCement.getSandMech3137CoarseId() + "-" +
                                sysCement.getSandMech1622FineId() + "-" +
                                sysCement.getSandMech0475Id() + "-" +
                                sysCement.getSandMech09Id() + "-" +
                                sysCement.getStonePowderId() + "-" +
                                sysCement.getMineralPowderId() + "-" +
                                sysCement.getFlyAshId() + "-" +
                                sysCement.getWaterReducerId() + "-" +
                                sysCement.getEfficiencyAgentId() + "-" +
                                sysCement.getExpansionAgentId() + "-" +

                                sysCement.getWater() + "-" +
                                sysCement.getCement() + "-" +
                                sysCement.getStone510() + "-" +
                                sysCement.getStone525() + "-" +
                                sysCement.getStone2040() + "-" +
                                sysCement.getStone1020() + "-" +
                                sysCement.getStone1030() + "-" +
                                sysCement.getStone010() + "-" +
                                sysCement.getStoneCoarse20315() + "-" +
                                sysCement.getSandRiverCoarse3137() + "-" +
                                sysCement.getSandRiver2330Med() + "-" +
                                sysCement.getSandRiver1622Fine() + "-" +
                                sysCement.getSandMech2330Med() + "-" +
                                sysCement.getSandMech3137Coarse() + "-" +
                                sysCement.getSandMech1622Fine() + "-" +
                                sysCement.getSandMech0475() + "-" +
                                sysCement.getSandMech09() + "-" +
                                sysCement.getStonePowder() + "-" +
                                sysCement.getMineralPowder() + "-" +
                                sysCement.getFlyAsh() + "-" +
                                sysCement.getWaterReducer() + "-" +
                                sysCement.getEfficiencyAgent() + "-" +
                                sysCement.getExpansionAgent() + "-" +
                                sysCement.getRegion() + "-" +
                                sysCement.getProductionDate() + "-" +
                                sysCement.getStrengthGrade() + "-" +
                                sysCement.getCompressive3d() + "-" +
                                sysCement.getCompressive7d() + "-" +
                                sysCement.getCompressive28d();
                wrapperSysMechanicalPerformanceMap.put(keySysMechanicalPerformance, sysCement);  // 使用一个唯一的组合键作为 map 的 key
            }
            System.out.println("数据库中的key" + wrapperSysMechanicalPerformanceMap);  // 打印生成的 key

            // 构建新的唯一键
            String keySysMechanicalPerformance = cementId + "-" + stone510Id + "-" + stone525Id + "-" + stone2040Id + "-" + stone1020Id + "-"
                    + stone1030Id + "-" + stone010Id + "-" + stone20315Id + "-" + sand3137Id + "-" + sand2330Id + "-"
                    + sand1622Id + "-" + sand2330BId + "-" + sand3137BId + "-" + sand1622BId + "-" + sand0475Id + "-"
                    + sand09Id + "-" + otherAdmixturesId + "-" + mineralPowderId + "-" + flyashId + "-"
                    + waterReducerId + "-" + efficiencyAgentId + "-" + sysSwellingId + "-" + water + "-" + cement
                    + "-" + stone510 + "-" + stone525 + "-" + stone2040 + "-" + stone1020 + "-" + stone1030 + "-" + stone010 + "-" +
                    stone20315 + "-" + sand3137 + "-" + sand2330 + "-" + sand1622 + "-" + sand2330B + "-" + sand3137B + "-" + sand1622B + "-" + sand0475 + "-" +
                    sand09 + "-" + otherAdmixturesStonePowder + "-" + mineralPowder + "-" + flyash + "-" + waterReducer + "-" + efficiencyAgent + "-" + swellinAagent + "-" +
                    regiona + "-" + productionDate + "-" + strengthGrade + "-" + compressive3d + "-" + compressive7d + "-" + compressive28d;



            System.out.println("现在的key" + keySysMechanicalPerformance);

            // 创建一个列表用于存储待插入的新数据
            List<SysMechanicalPerformance> newDataList = new ArrayList<>();

            // 检查是否已经存在相同的力学性能数据
            if (wrapperSysMechanicalPerformanceMap.containsKey(keySysMechanicalPerformance)) {
                // 数据已存在，跳过插入
                System.out.println("力学性能数据已存在，跳过啦哈哈哈哈哈");
            } else {


                // 数据不存在，插入新数据
                SysMechanicalPerformance newSysMechanicalPerformance = new SysMechanicalPerformance();
                newSysMechanicalPerformance.setCementId(cementId);
                newSysMechanicalPerformance.setStone510Id(stone510Id);
                newSysMechanicalPerformance.setStone525Id(stone525Id);
                newSysMechanicalPerformance.setStone2040Id(stone2040Id);
                newSysMechanicalPerformance.setStone1020Id(stone1020Id);
                newSysMechanicalPerformance.setStone1030Id(stone1030Id);
                newSysMechanicalPerformance.setStone010Id(stone010Id);
                newSysMechanicalPerformance.setStone2031Id(stone20315Id);
                newSysMechanicalPerformance.setSandRiverCoarse3137Id(sand3137Id);
                newSysMechanicalPerformance.setSandRiver2330MedId(sand2330Id);
                newSysMechanicalPerformance.setSandRiver1622FineId(sand1622Id);
                newSysMechanicalPerformance.setSandMech2330MedId(sand2330BId);
                newSysMechanicalPerformance.setSandMech3137CoarseId(sand3137BId);
                newSysMechanicalPerformance.setSandMech1622FineId(sand1622BId);
                newSysMechanicalPerformance.setSandMech0475Id(sand0475Id);
                newSysMechanicalPerformance.setSandMech09Id(sand09Id);
                newSysMechanicalPerformance.setStonePowderId(otherAdmixturesId);
                newSysMechanicalPerformance.setMineralPowderId(mineralPowderId);
                newSysMechanicalPerformance.setFlyAshId(flyashId);
                newSysMechanicalPerformance.setWaterReducerId(waterReducerId);
                newSysMechanicalPerformance.setEfficiencyAgentId(efficiencyAgentId);
                newSysMechanicalPerformance.setExpansionAgentId(sysSwellingId);//22

                newSysMechanicalPerformance.setWater(water);
                newSysMechanicalPerformance.setCement(cement);
                newSysMechanicalPerformance.setStone510(stone510);
                newSysMechanicalPerformance.setStone525(stone525);
                newSysMechanicalPerformance.setStone2040(stone2040);
                newSysMechanicalPerformance.setStone1020(stone1020);
                newSysMechanicalPerformance.setStone1030(stone1030);
                newSysMechanicalPerformance.setStone010(stone010);
                newSysMechanicalPerformance.setStoneCoarse20315(stone20315);
                newSysMechanicalPerformance.setSandRiverCoarse3137(sand3137);
                newSysMechanicalPerformance.setSandRiver2330Med(sand2330);
                newSysMechanicalPerformance.setSandRiver1622Fine(sand1622);
                newSysMechanicalPerformance.setSandMech2330Med(sand2330B);
                newSysMechanicalPerformance.setSandMech3137Coarse(sand3137B);

                newSysMechanicalPerformance.setSandMech1622Fine(sand1622B);
                newSysMechanicalPerformance.setSandMech0475(sand0475);
                newSysMechanicalPerformance.setSandMech09(sand09);

                newSysMechanicalPerformance.setStonePowder(otherAdmixturesStonePowder);

                newSysMechanicalPerformance.setMineralPowder(mineralPowder);
                newSysMechanicalPerformance.setFlyAsh(flyash);
                newSysMechanicalPerformance.setWaterReducer(waterReducer);

                newSysMechanicalPerformance.setEfficiencyAgent(efficiencyAgent);
                newSysMechanicalPerformance.setExpansionAgent(swellinAagent);

                /* 掺量结束*/

                newSysMechanicalPerformance.setRegion(regiona);
                newSysMechanicalPerformance.setProductionDate(productionDate);
                newSysMechanicalPerformance.setStrengthGrade(strengthGrade);


                newSysMechanicalPerformance.setCompressive3d(compressive3d);
                newSysMechanicalPerformance.setCompressive7d(compressive7d);
                newSysMechanicalPerformance.setCompressive28d(compressive28d);
                newSysMechanicalPerformance.setCreateTime(LocalDateTime.now());

                // 将新数据添加到列表中
                newDataList.add(newSysMechanicalPerformance);

                // 插入新数据
              //  sysMechanicalPerformanceService.save(newSysMechanicalPerformance);

                System.out.println("力学性能数据不存在，已插入哈哈哈哈哈");
            }

            // 批量插入数据（如果有新数据需要插入）
            if (!newDataList.isEmpty()) {
                sysMechanicalPerformanceService.saveBatch(newDataList);
                System.out.println("成功批量插入" + newDataList.size() + "条力学性能数据");
            }
        }

//        //审核通过之后写入excel  更新excel路径
        updateMechanicalExcelUrlAfterApproval();
        return AjaxResult.success();
    }


    /**
     * 审核通过后更新力学性能Excel路径（单记录模式）
     * 确保只更新mechanicalPerformanceUrl字段，其他字段保持不变
     */
//    public AjaxResult updateMechanicalExcelUrlAfterApproval() {
//        try {
//            // 1. 生成Excel文件并获取路径
//            String mpExcelPath = mechanicalPerformanceUrl();
//            if (StringUtils.isEmpty(mpExcelPath)) {
//                return AjaxResult.error("Excel生成失败，路径为空");
//            }
//
//            // 2. 查询是否已有记录
//            SysMaterialSlumpUrl existingRecord = sysMaterialSlumpUrlService.getOne(new QueryWrapper<>(), false);
//
//            if (existingRecord == null) {
//                // 没有记录，创建新记录，同时设置必填字段的默认值
//                SysMaterialSlumpUrl newRecord = new SysMaterialSlumpUrl();
//                newRecord.setMechanicalPerformanceUrl(mpExcelPath);
//                // 为NOT NULL字段设置默认值
//                newRecord.setSlumpUrl(""); // 或其他默认值
//
//                boolean success = sysMaterialSlumpUrlService.save(newRecord);
//                if (success) {
//                    return AjaxResult.success("Excel路径保存成功");
//                } else {
//                    return AjaxResult.error("数据保存失败");
//                }
//            } else {
//                // 已有记录，只更新mechanicalPerformanceUrl字段
//                existingRecord.setMechanicalPerformanceUrl(mpExcelPath);
//                // 其他字段(existingRecord.getSlumpUrl())保持原值
//
//                boolean success = sysMaterialSlumpUrlService.updateById(existingRecord);
//                if (success) {
//                    return AjaxResult.success("Excel路径更新成功");
//                } else {
//                    return AjaxResult.error("数据更新失败");
//                }
//            }
//        } catch (Exception e) {
//            log.error("更新力学性能Excel路径失败", e);
//            return AjaxResult.error("处理失败: " + e.getMessage());
//        }
//    }
//

    public AjaxResult updateMechanicalExcelUrlAfterApproval() {
        try {
            // 1. 生成Excel文件并获取路径
            String mpExcelPath = mechanicalPerformanceUrl();
            if (StringUtils.isEmpty(mpExcelPath)) {
                return AjaxResult.error("Excel生成失败，路径为空");
            }

            // 2. 查询第一条记录
            QueryWrapper<SysMaterialSlumpUrl> queryWrapper = new QueryWrapper<>();
            queryWrapper.last("LIMIT 1"); // 确保只获取第一条记录
            SysMaterialSlumpUrl firstRecord = sysMaterialSlumpUrlService.getOne(queryWrapper, false);

            if (firstRecord == null) {
                // 没有记录，创建新记录
                SysMaterialSlumpUrl newRecord = new SysMaterialSlumpUrl();
                newRecord.setMechanicalPerformanceUrl(mpExcelPath);
                // 设置其他NOT NULL字段的默认值
                newRecord.setSlumpUrl(""); // 或其他默认值

                boolean success = sysMaterialSlumpUrlService.save(newRecord);
                if (success) {
                    return AjaxResult.success("Excel路径保存成功");
                } else {
                    return AjaxResult.error("数据保存失败");
                }
            } else {
                // 已有记录，只更新mechanicalPerformanceUrl字段
                firstRecord.setMechanicalPerformanceUrl(mpExcelPath);

                boolean success = sysMaterialSlumpUrlService.updateById(firstRecord);
                if (success) {
                    return AjaxResult.success("Excel路径更新成功");
                } else {
                    return AjaxResult.error("数据更新失败");
                }
            }
        } catch (Exception e) {
            log.error("更新力学性能Excel路径失败", e);
            return AjaxResult.error("处理失败: " + e.getMessage());
        }
    }


    public  String mechanicalPerformanceUrl(){


            // 查询膨胀剂数据
            List<SysMechanicalPerformance> agentList = sysMechanicalPerformanceService.list();

            // 获取地区信息，转换成 Map 以便后续使用
            List<Region> listRegion = regionService.list();
            Map<Integer, Region> regionMap = listRegion.stream()
                    .collect(Collectors.toMap(Region::getId, Function.identity()));


            // 获取水泥信息，转换成 Map 以便后续使用
            List<SysCement> listCement = sysCementService.list();
            Map<Integer, SysCement> CementMap = listCement.stream()
                    .collect(Collectors.toMap(SysCement::getCementId, Function.identity()));


            // 获取水泥信息，转换成 Map 以便后续使用
            List<SysStone> listStone = sysStoneService.list();
            Map<Integer, SysStone> StoneMap = listStone.stream()
                    .collect(Collectors.toMap(SysStone::getStoneId, Function.identity()));


            // 获取砂信息，转换成 Map 以便后续使用
            List<SysSand> listSande = sysSandService.list();
            Map<Integer, SysSand> SandeMap = listSande.stream()
                    .collect(Collectors.toMap(SysSand::getSandId, Function.identity()));


            // 获取石粉信息，转换成 Map 以便后续使用
            List<SysOtherAdmixtures> listOtherAdmixtures = sysOtherAdmixturesService.list();
            Map<Integer, SysOtherAdmixtures> OtherAdmixturesMap = listOtherAdmixtures.stream()
                    .collect(Collectors.toMap(SysOtherAdmixtures::getAdmixturesId, Function.identity()));


            // 获取矿粉信息，转换成 Map 以便后续使用
            List<SysMineralPowder> listMineralPowder = sysMineralPowderService.list();
            Map<Integer, SysMineralPowder> SysMineralPowderMap = listMineralPowder.stream()
                    .collect(Collectors.toMap(SysMineralPowder::getPowderId, Function.identity()));

            // 获取粉煤灰信息，转换成 Map 以便后续使用
            List<SysFlyash> listFlyash = sysFlyashService.list();
            Map<Integer, SysFlyash> flyashMap = listFlyash.stream()
                    .collect(Collectors.toMap(SysFlyash::getFlyashId, Function.identity()));


            // 获取减水剂信息，转换成 Map 以便后续使用
            List<SysWaterReducer> listSysWaterReducer = sysWaterReducerService.list();
            Map<Integer, SysWaterReducer> SysWaterReducerMap = listSysWaterReducer.stream()
                    .collect(Collectors.toMap(SysWaterReducer::getReducerId, Function.identity()));


            // 获取增效剂信息，转换成 Map 以便后续使用
            List<SysEfficiencyAgent> listEfficiencyAgent = sysEfficiencyAgent.list();
            Map<Integer, SysEfficiencyAgent> efficiencyAgentMap = listEfficiencyAgent.stream()
                    .collect(Collectors.toMap(SysEfficiencyAgent::getAgentId, Function.identity()));


            // 获取增效剂信息，转换成 Map 以便后续使用
            List<SysSwellingagent> listSwellingagent = sysSwellingagentService.list();
            Map<Integer, SysSwellingagent> swellingagentMap = listSwellingagent.stream()
                    .collect(Collectors.toMap(SysSwellingagent::getSwellingagentId, Function.identity()));

            // 准备返回的 VO 列表
            List<SysMechanicalPerformanceThirdVO> agentVOList = new ArrayList<>();
            for (SysMechanicalPerformance smp : agentList) {
                SysMechanicalPerformanceThirdVO vo = new SysMechanicalPerformanceThirdVO();
                BeanUtils.copyProperties(smp, vo);

                // 设置地区名称
                Integer regionId = smp.getRegion();
                Region region = regionMap.get(regionId);
                if (region != null) {
                    vo.setRegionNameStr(region.getFullName());
                }

                LocalDateTime productionDate = smp.getProductionDate();
                if (productionDate != null) {
                    vo.setProductionDate(productionDate);
                }


                //查询水泥数据
                Integer cementId = smp.getCementId();
                if (cementId != null) {
                    SysCement sysCement = CementMap.get(cementId);
                    if (sysCement != null) {
                        vo.setCementModel(sysCement.getModel());
                        vo.setCementCaoContent(sysCement.getCaoContent());
                        vo.setCementSio2Content(sysCement.getSio2Content());
                        vo.setCementAl2o3Content(sysCement.getAl2o3Content());
                        vo.setCementCompressiveStrength28d(sysCement.getCompressiveStrength28d());
                        vo.setCementStrengthGrade(sysCement.getStrengthGrade());
                        Integer regionName = sysCement.getRegionName();
                        if (regionName != null) {
                            Region region1 = regionMap.get(regionName);
                            if (region1 != null) {
                                vo.setCementRegionNameStr(region1.getFullName());
                            }

                        }
                    }


                }


                //石头 5-10
                Integer stone510Id = smp.getStone510Id();
                if (stone510Id != null) {
                    SysStone sysStone510 = StoneMap.get(stone510Id);
                    if (sysStone510 != null) {
                        System.out.println("哈哈哈510" + sysStone510);
                        vo.setStoneModel510(sysStone510.getModel());
                        vo.setStoneSpecification510(sysStone510.getStoneSpecification());
                        vo.setStoneStackingDensity510(sysStone510.getStackingDensity());
                        vo.setStoneCompactDensity510(sysStone510.getCompactDensity());
                        vo.setStoneBulkdensity510(sysStone510.getBulkDensity());
                        Integer regionNameStone510 = sysStone510.getRegionName();
                        if (regionNameStone510 != null) {
                            Region region1 = regionMap.get(regionNameStone510);
                            if (region1 != null) {
                                vo.setStoneRegionNameStr510(region1.getFullName());
                            }
                        }
                    }

                }

                //石头 5-25
                Integer stone525Id = smp.getStone525Id();
                if (stone525Id != null) {
                    SysStone sysStone525 = StoneMap.get(stone525Id);
                    if (sysStone525 != null) {
                        System.out.println("哈哈哈510" + sysStone525);
                        vo.setStoneModel525(sysStone525.getModel());
                        vo.setStoneSpecification525(sysStone525.getStoneSpecification());
                        vo.setStoneStackingDensity525(sysStone525.getStackingDensity());
                        vo.setStoneCompactDensity525(sysStone525.getCompactDensity());
                        vo.setStoneBulkdensity525(sysStone525.getBulkDensity());
                        Integer regionNameStone525 = sysStone525.getRegionName();
                        if (regionNameStone525 != null) {
                            Region region1 = regionMap.get(regionNameStone525);
                            if (region1 != null) {
                                vo.setStoneRegionNameStr525(region1.getFullName());
                            }
                        }
                    }
                }


                //石头 2040
                Integer stone2040Id = smp.getStone525Id();
                if (stone2040Id != null) {
                    SysStone sysStone2040 = StoneMap.get(stone2040Id);
                    if (sysStone2040 != null) {
                        System.out.println("哈哈哈510" + sysStone2040);
                        vo.setStoneModel2040(sysStone2040.getModel());
                        vo.setStoneSpecification2040(sysStone2040.getStoneSpecification());
                        vo.setStoneStackingDensity2040(sysStone2040.getStackingDensity());
                        vo.setStoneCompactDensity2040(sysStone2040.getCompactDensity());
                        vo.setStoneBulkdensity2040(sysStone2040.getBulkDensity());
                        Integer regionNameStone2040 = sysStone2040.getRegionName();
                        if (regionNameStone2040 != null) {
                            Region region1 = regionMap.get(regionNameStone2040);
                            if (region1 != null) {
                                vo.setStoneRegionNameStr2040(region1.getFullName());
                            }
                        }
                    }
                }


                //石头 10-20
                Integer stone1020Id = smp.getStone1020Id();
                if (stone1020Id != null) {
                    SysStone sysStone1020 = StoneMap.get(stone1020Id);
                    if (sysStone1020 != null) {
                        System.out.println("哈哈哈510" + sysStone1020);
                        vo.setStoneModel1020(sysStone1020.getModel());
                        vo.setStoneSpecification1020(sysStone1020.getStoneSpecification());
                        vo.setStoneStackingDensity1020(sysStone1020.getStackingDensity());
                        vo.setStoneCompactDensity1020(sysStone1020.getCompactDensity());
                        vo.setStoneBulkdensity1020(sysStone1020.getBulkDensity());
                        Integer regionNameStone1020 = sysStone1020.getRegionName();
                        if (regionNameStone1020 != null) {
                            Region region1 = regionMap.get(regionNameStone1020);
                            if (region1 != null) {
                                vo.setStoneRegionNameStr1020(region1.getFullName());
                            }
                        }
                    }
                }


                //石头 10-30
                Integer stone1030Id = smp.getStone1030Id();
                if (stone1030Id != null) {
                    SysStone sysStone1030 = StoneMap.get(stone1030Id);
                    if (sysStone1030 != null) {
                        System.out.println("哈哈哈510" + sysStone1030);
                        vo.setStoneModel1030(sysStone1030.getModel());
                        vo.setStoneSpecification1030(sysStone1030.getStoneSpecification());
                        vo.setStoneStackingDensity1030(sysStone1030.getStackingDensity());
                        vo.setStoneCompactDensity1030(sysStone1030.getCompactDensity());
                        vo.setStoneBulkdensity1030(sysStone1030.getBulkDensity());
                        Integer regionNameStone1030 = sysStone1030.getRegionName();
                        if (regionNameStone1030 != null) {
                            Region region1 = regionMap.get(regionNameStone1030);
                            if (region1 != null) {
                                vo.setStoneRegionNameStr1030(region1.getFullName());
                            }
                        }
                    }
                }

                vo.setStone2031(smp.getStoneCoarse20315());
                //石头 0-10
                Integer stone010Id = smp.getStone010Id();
                if (stone010Id != null) {
                    SysStone sysStone010 = StoneMap.get(stone010Id);
                    if (sysStone010 != null) {

                        vo.setStoneModel010(sysStone010.getModel());
                        vo.setStoneSpecification010(sysStone010.getStoneSpecification());
                        vo.setStoneStackingDensity010(sysStone010.getStackingDensity());
                        vo.setStoneCompactDensity010(sysStone010.getCompactDensity());
                        vo.setStoneBulkdensity010(sysStone010.getBulkDensity());
                        Integer regionNameStone010 = sysStone010.getRegionName();
                        if (regionNameStone010 != null) {
                            Region region1 = regionMap.get(regionNameStone010);
                            if (region1 != null) {
                                vo.setStoneRegionNameStr010(region1.getFullName());
                            }
                        }
                    }
                }

                //石头 20-315
                Integer stone20315Id = smp.getStone2031Id();
                if (stone20315Id != null) {
                    SysStone sysStone20315 = StoneMap.get(stone20315Id);
                    if (sysStone20315 != null) {

                        vo.setStoneModel20315(sysStone20315.getModel());
                        vo.setStoneSpecification20315(sysStone20315.getStoneSpecification());
                        vo.setStoneStackingDensity20315(sysStone20315.getStackingDensity());
                        vo.setStoneCompactDensity20315(sysStone20315.getCompactDensity());
                        vo.setStoneBulkdensity20315(sysStone20315.getBulkDensity());
                        Integer regionNameStone20315 = sysStone20315.getRegionName();
                        if (regionNameStone20315 != null) {
                            Region region1 = regionMap.get(regionNameStone20315);
                            if (region1 != null) {
                                vo.setStoneRegionNameStr20315(region1.getFullName());
                            }
                        }
                    }
                }


                //砂31-37
                vo.setSand3137(smp.getSandRiverCoarse3137());
                Integer sandRiverCoarse3137Id = smp.getSandRiverCoarse3137Id();
                if (sandRiverCoarse3137Id != null) {
                    SysSand sysSand3137 = SandeMap.get(sandRiverCoarse3137Id);
                    if (sysSand3137 != null) {
                        vo.setSandType3137(sysSand3137.getType());
                        vo.setSandFineness3137(sysSand3137.getFineness());
                        vo.setSandBulkDensity3137(sysSand3137.getBulkDensity());
                        vo.setSandCompactDensity3137(sysSand3137.getCompactDensity());
                        vo.setSandApparentDensity3137(sysSand3137.getApparentDensity());
                        vo.setSandParticleSizeDistribution3137(sysSand3137.getParticleSizeDistribution());
                        Integer regionName3137 = sysSand3137.getRegionName();
                        if (regionName3137 != null) {
                            Region region1 = regionMap.get(regionName3137);
                            if (region1 != null) {
                                vo.setSandRegionNameStr3137(region1.getFullName());
                            }
                        }


                    }


                }


                //砂23-30
                vo.setSand2330(smp.getSandRiver2330Med());
                Integer sandRiverCoarse2330Id = smp.getSandRiver2330MedId();
                if (sandRiverCoarse2330Id != null) {
                    SysSand sysSand2330 = SandeMap.get(sandRiverCoarse2330Id);
                    if (sysSand2330 != null) {
                        vo.setSandType2330(sysSand2330.getType());
                        vo.setSandFineness2330(sysSand2330.getFineness());
                        vo.setSandBulkDensity2330(sysSand2330.getBulkDensity());
                        vo.setSandCompactDensity2330(sysSand2330.getCompactDensity());
                        vo.setSandApparentDensity2330(sysSand2330.getApparentDensity());
                        vo.setSandParticleSizeDistribution2330(sysSand2330.getParticleSizeDistribution());
                        Integer regionName2330 = sysSand2330.getRegionName();
                        if (regionName2330 != null) {
                            Region region1 = regionMap.get(regionName2330);
                            if (region1 != null) {
                                vo.setSandRegionNameStr2330(region1.getFullName());
                            }
                        }


                    }


                }


                //砂16-22
                vo.setSand1622(smp.getSandRiver1622Fine());
                Integer sandRiverCoarse1622Id = smp.getSandRiver1622FineId();
                if (sandRiverCoarse1622Id != null) {
                    SysSand sysSand1622 = SandeMap.get(sandRiverCoarse1622Id);
                    if (sysSand1622 != null) {
                        vo.setSandType1622(sysSand1622.getType());
                        vo.setSandFineness1622(sysSand1622.getFineness());
                        vo.setSandBulkDensity1622(sysSand1622.getBulkDensity());
                        vo.setSandCompactDensity1622(sysSand1622.getCompactDensity());
                        vo.setSandApparentDensity1622(sysSand1622.getApparentDensity());
                        vo.setSandParticleSizeDistribution1622(sysSand1622.getParticleSizeDistribution());
                        Integer regionName1622 = sysSand1622.getRegionName();
                        if (regionName1622 != null) {
                            Region region1 = regionMap.get(regionName1622);
                            if (region1 != null) {
                                vo.setSandRegionNameStr1622(region1.getFullName());
                            }
                        }

                    }

                }


                //砂2330B
                vo.setSand2330B(smp.getSandMech2330Med());
                Integer sandRiverCoarse2330BId = smp.getSandMech2330MedId();
                if (sandRiverCoarse2330BId != null) {
                    SysSand sysSand2330B = SandeMap.get(sandRiverCoarse2330BId);
                    if (sysSand2330B != null) {
                        vo.setSandType2330B(sysSand2330B.getType());
                        vo.setSandFineness2330B(sysSand2330B.getFineness());
                        vo.setSandBulkDensity2330B(sysSand2330B.getBulkDensity());
                        vo.setSandCompactDensity2330B(sysSand2330B.getCompactDensity());
                        vo.setSandApparentDensity2330B(sysSand2330B.getApparentDensity());
                        vo.setSandParticleSizeDistribution2330B(sysSand2330B.getParticleSizeDistribution());
                        Integer regionName2330B = sysSand2330B.getRegionName();
                        if (regionName2330B != null) {
                            Region region1 = regionMap.get(regionName2330B);
                            if (region1 != null) {
                                vo.setSandRegionNameStr2330B(region1.getFullName());
                            }
                        }

                    }

                }


                //砂31-37B
                vo.setSand3137B(smp.getSandMech3137Coarse());
                Integer sandRiverCoarse3137BId = smp.getSandMech3137CoarseId();
                if (sandRiverCoarse3137BId != null) {
                    SysSand sysSand3137B = SandeMap.get(sandRiverCoarse3137BId);
                    if (sysSand3137B != null) {
                        vo.setSandType3137B(sysSand3137B.getType());
                        vo.setSandFineness3137B(sysSand3137B.getFineness());
                        vo.setSandBulkDensity3137B(sysSand3137B.getBulkDensity());
                        vo.setSandCompactDensity3137B(sysSand3137B.getCompactDensity());
                        vo.setSandApparentDensity3137B(sysSand3137B.getApparentDensity());
                        vo.setSandParticleSizeDistribution3137B(sysSand3137B.getParticleSizeDistribution());
                        Integer regionName3137B = sysSand3137B.getRegionName();
                        if (regionName3137B != null) {
                            Region region1 = regionMap.get(regionName3137B);
                            if (region1 != null) {
                                vo.setSandRegionNameStr3137B(region1.getFullName());
                            }
                        }

                    }
                }


                //砂16-22
                vo.setSand1622B(smp.getSandMech1622Fine());
                Integer sandRiverCoarse1622BId = smp.getSandMech1622FineId();
                if (sandRiverCoarse1622BId != null) {
                    SysSand sysSand1622B = SandeMap.get(sandRiverCoarse1622BId);
                    if (sysSand1622B != null) {
                        vo.setSandType1622B(sysSand1622B.getType());
                        vo.setSandFineness1622B(sysSand1622B.getFineness());
                        vo.setSandBulkDensity1622B(sysSand1622B.getBulkDensity());
                        vo.setSandCompactDensity1622B(sysSand1622B.getCompactDensity());
                        vo.setSandApparentDensity1622B(sysSand1622B.getApparentDensity());
                        vo.setSandParticleSizeDistribution1622B(sysSand1622B.getParticleSizeDistribution());
                        Integer regionName1622B = sysSand1622B.getRegionName();
                        if (regionName1622B != null) {
                            Region region1 = regionMap.get(regionName1622B);
                            if (region1 != null) {
                                vo.setSandRegionNameStr1622B(region1.getFullName());
                            }
                        }

                    }

                }


                //砂04-75
                vo.setSand0475(smp.getSandMech0475());
                Integer sandRiverCoarse0475Id = smp.getSandMech0475Id();
                if (sandRiverCoarse0475Id != null) {
                    SysSand sysSand0475 = SandeMap.get(sandRiverCoarse0475Id);
                    if (sysSand0475 != null) {
                        vo.setSandType0475(sysSand0475.getType());
                        vo.setSandFineness0475(sysSand0475.getFineness());
                        vo.setSandBulkDensity0475(sysSand0475.getBulkDensity());
                        vo.setSandCompactDensity0475(sysSand0475.getCompactDensity());
                        vo.setSandApparentDensity0475(sysSand0475.getApparentDensity());
                        vo.setSandParticleSizeDistribution0475(sysSand0475.getParticleSizeDistribution());
                        Integer regionName0475 = sysSand0475.getRegionName();
                        if (regionName0475 != null) {
                            Region region1 = regionMap.get(regionName0475);
                            if (region1 != null) {
                                vo.setSandRegionNameStr0475(region1.getFullName());
                            }
                        }

                    }
                }

//砂0-9
                vo.setSand09(smp.getSandMech09());
                Integer sandRiverCoarse09Id = smp.getSandMech09Id();
                if (sandRiverCoarse09Id != null) {
                    SysSand sysSand09 = SandeMap.get(sandRiverCoarse09Id);
                    if (sysSand09 != null) {
                        vo.setSandType09(sysSand09.getType());
                        vo.setSandFineness09(sysSand09.getFineness());
                        vo.setSandBulkDensity09(sysSand09.getBulkDensity());
                        vo.setSandCompactDensity09(sysSand09.getCompactDensity());
                        vo.setSandApparentDensity09(sysSand09.getApparentDensity());
                        vo.setSandParticleSizeDistribution09(sysSand09.getParticleSizeDistribution());
                        Integer regionName09 = sysSand09.getRegionName();
                        if (regionName09 != null) {
                            Region region1 = regionMap.get(regionName09);
                            if (region1 != null) {
                                vo.setSandRegionNameStr09(region1.getFullName());
                            }
                        }

                    }
                }


                //石粉
                vo.setAdmixtures(smp.getStonePowder());
                Integer stonePowderId = smp.getStonePowderId();
                if (stonePowderId != null) {
                    SysOtherAdmixtures sysOtherAdmixtures = OtherAdmixturesMap.get(stonePowderId);
                    if (sysOtherAdmixtures != null) {
                        vo.setAdmixturesModel(sysOtherAdmixtures.getModel());
                        vo.setAdmixturesFineness(sysOtherAdmixtures.getFineness());
                        vo.setAdmixturesMoistureContent(sysOtherAdmixtures.getMoistureContent());
                        vo.setAdmixturesActivityIndex28d(sysOtherAdmixtures.getActivityIndex28d());
                        Integer regionName09 = sysOtherAdmixtures.getRegionName();
                        if (regionName09 != null) {
                            Region region1 = regionMap.get(regionName09);
                            if (region1 != null) {
                                vo.setAdmixturesRegionNameStr(region1.getFullName());
                            }
                        }

                    }
                }


                //矿粉
                vo.setMineralPowder(smp.getMineralPowder());
                Integer mineralPowderId = smp.getMineralPowderId();
                if (mineralPowderId != null) {
                    SysMineralPowder sysMineralPowder = SysMineralPowderMap.get(mineralPowderId);
                    if (sysMineralPowder != null) {
                        vo.setMineralModel(sysMineralPowder.getModel());
                        vo.setMineralSlagGrade(sysMineralPowder.getSlagGrade());
                        vo.setMineralFineness(sysMineralPowder.getFineness());
                        vo.setMineralMoistureContent(sysMineralPowder.getMoistureContent());
                        vo.setMineralActivityIndex28d(sysMineralPowder.getActivityIndex28d());

                        Integer regionName = sysMineralPowder.getRegionName();
                        if (regionName != null) {
                            Region region1 = regionMap.get(regionName);
                            if (region1 != null) {
                                vo.setMineralRegionNameStr(region1.getFullName());
                            }
                        }

                    }
                }


                //粉煤灰
                vo.setFlyash(smp.getFlyAsh());
                Integer flyAshId = smp.getFlyAshId();
                if (flyAshId != null) {
                    SysFlyash sysFlyash = flyashMap.get(flyAshId);
                    if (sysFlyash != null) {
                        vo.setFlyashGrade(sysFlyash.getGrade());
                        vo.setFlyashFactoryGrade(sysFlyash.getFactoryGrade());
                        vo.setFlyashFineness(sysFlyash.getFineness());
                        vo.setFlyashMoistureContent(sysFlyash.getMoistureContent());
                        vo.setFlyashActivityIndex28d(sysFlyash.getActivityIndex28d());

                        Integer regionName = sysFlyash.getRegionName();
                        if (regionName != null) {
                            Region region1 = regionMap.get(regionName);
                            if (region1 != null) {
                                vo.setFlyashRegionNameStr(region1.getFullName());
                            }
                        }

                    }
                }


                //减水剂

                vo.setReducer(smp.getWaterReducer());
                Integer waterReducerId = smp.getWaterReducerId();
                if (waterReducerId != null) {
                    SysWaterReducer sysWaterReducer = SysWaterReducerMap.get(waterReducerId);
                    if (sysWaterReducer != null) {
                        vo.setReducerModel(sysWaterReducer.getModel());
                        vo.setReducerSolidContent(sysWaterReducer.getSolidContent());
                        vo.setReducerCementPsteFlow(sysWaterReducer.getCementPasteFlow());
                        vo.setReducerReducingRate(sysWaterReducer.getReducingRate());
                        vo.setReducerRegionNameStr(sysWaterReducer.getSourceName());

                    }
                }


                //增效剂
                vo.setEfficiencyAgentAgent(smp.getEfficiencyAgent());
                Integer efficiencyAgentId = smp.getEfficiencyAgentId();
                if (efficiencyAgentId != null) {
                    SysEfficiencyAgent efficiencyAgent = efficiencyAgentMap.get(efficiencyAgentId);
                    if (efficiencyAgent != null) {
                        vo.setEfficiencyAgentModel(efficiencyAgent.getModel());
                        vo.setEfficiencyAgentSourceName(efficiencyAgent.getSourceName());
                    }
                }


                //膨胀剂
                vo.setSwellingAgent(smp.getExpansionAgent());
                Integer swellingAgentId = smp.getExpansionAgentId();
                if (swellingAgentId != null) {
                    SysSwellingagent sysSwellingagent = swellingagentMap.get(swellingAgentId);
                    if (sysSwellingagent != null) {
                        vo.setSwellingagentModel(sysSwellingagent.getModel());
                        vo.setSwellingagentSourceName(sysSwellingagent.getSourceName());

                    }
                }


                agentVOList.add(vo);
            }
            //String excelName = rawMaterialsDTO.getExcelName();
            // 生成 Excel 文件并保存到本地
            String filePath = saveExcelToLocalV2(agentVOList, "抗压强度");

          // map.put("compressiveStrength",filePath);
            // 返回文件的 URL
            // 返回 AjaxResult，可以包含文件的 URL
            // return AjaxResult.success("文件已生成", filePath);


        return filePath;
    }



    private String saveExcelToLocalV2(List<SysMechanicalPerformanceThirdVO> agentVOList, String excelName) {
        // 创建 Excel 工具类
        ExcelUtil<SysMechanicalPerformanceThirdVO> util = new ExcelUtil<>(SysMechanicalPerformanceThirdVO.class);


        UUID uuid = UUID.randomUUID();
        int hash = Math.abs(uuid.hashCode()); // 获取 hashCode 并取正数
        int sevenDigitNumber = hash % 10000; // 取模确保是7位数字以内
        String number = String.format("%03d", sevenDigitNumber); // 补0凑足3位
        // 生成一个唯一的文件名，可以包含时间戳或其他方式
        String fileName = System.currentTimeMillis() + "_" + number + ".xlsx";

        // 设置文件保存路径（这里假设文件存储在服务器的 /uploads/ 文件夹中）
        // String filePath = "C:\\Users\\Administrator\\Desktop\\测试\\excel\\" + fileName;
        String filePath = mechanicalPerformanceExcelPath + fileName;
        // 创建目录（如果不存在）
        File dir = new File(mechanicalPerformanceExcelPath);
        if (!dir.exists()) {
            boolean created = dir.mkdirs(); // 创建目录（支持多级）
            if (created) {
                System.out.println("目录已创建: " + dir.getAbsolutePath());
            } else {
                System.out.println("目录创建失败！");
            }
        }


/*        ExcelFileHistory excelFileHistory = new ExcelFileHistory();
        excelFileHistory.setFileName(excelName);
        excelFileHistory.setFilePath(filePath);
        excelFileHistory.setCreateTime(LocalDateTime.now());
        excelFileHistory.setDeleteTime(0);
        excelFileHistory.setVersion(0);
        excelFileHistory.setType(0);//力学
        excelFileHistory.setUserId(SecurityUtils.getUserId());
        excelFileHistoryService.save(excelFileHistory);*/


/*        SysExcelAudit sysExcelAudit = new SysExcelAudit();

        sysExcelAudit.setTableName(excelName);
        sysExcelAudit.setFilePath(filePath);
        sysExcelAudit.setCreateTime(LocalDateTime.now());
        sysExcelAudit.setDeleteTime(0);
        sysExcelAudit.setVersion(0);
        sysExcelAudit.setType(0);//力学
        sysExcelAudit.setUserId(SecurityUtils.getUserId());
        sysExcelAuditService.save(sysExcelAudit);*/


        try {
            // 将数据导出到本地文件
            util.exportExcelToLocal(agentVOList, filePath);
        } catch (IOException e) {
            e.printStackTrace();
            throw new RuntimeException("导出文件失败", e);
        }

        return filePath;
    }






    /*水泥插入校验*/
    private AjaxResult saveSysCement(String filePath, String id, Integer status) {


        ObjectMapper objectMapper = new ObjectMapper();
        List<List<String>> data;
        try {
            // 检查文件是否存在
            File jsonFile = new File(filePath);
            if (!jsonFile.exists()) {
                return AjaxResult.error("文件不存在: " + filePath);
            }

            // 解析 JSON 文件为二维数组（每一行是一条水泥记录）
            data = objectMapper.readValue(jsonFile, new com.fasterxml.jackson.core.type.TypeReference<List<List<String>>>() {
            });
        } catch (IOException e) {
            e.printStackTrace();
            return AjaxResult.error("JSON 文件解析失败: " + e.getMessage());
        }

        int successfulInserts = 0;

        // 获取所有已存在的水泥记录并存储在一个集合中
        LambdaQueryWrapper<SysCement> wrapper = new LambdaQueryWrapper<>();
        List<SysCement> list = sysCementService.list(wrapper);
        Map<String, SysCement> sysCementMap = new HashMap<>();

        for (SysCement sysCement : list) {
            String key = sysCement.getModel() + "-" + sysCement.getRegionName() + "-" + sysCement.getStrengthGrade() +
                    "-" + sysCement.getCaoContent() + "-" + sysCement.getSio2Content() + "-" + sysCement.getAl2o3Content() + "-" + sysCement.getCompressiveStrength28d();
            sysCementMap.put(key, sysCement);  // 使用一个唯一的组合键作为 map 的 key
        }

        // 创建一个临时列表，用于存储要插入的数据
        List<SysCement> batchInsertList = new ArrayList<>();

        // 遍历每条水泥数据
        for (List<String> record : data) {
            if (record.size() != 7) {
                System.err.println("无效数据格式: " + record);
                continue;
            }

            try {
                // 解析数据
                String model = record.get(0);
                BigDecimal cao = new BigDecimal(record.get(1));
                BigDecimal sio2 = new BigDecimal(record.get(2));
                BigDecimal al2o3 = new BigDecimal(record.get(3));
                BigDecimal compressive = new BigDecimal(record.get(4));
                BigDecimal strength = new BigDecimal(record.get(5));
                int region = Integer.parseInt(record.get(6));

                // 确保所有 BigDecimal 保留两位小数
                cao = cao.setScale(2, RoundingMode.HALF_UP);
                sio2 = sio2.setScale(2, RoundingMode.HALF_UP);
                al2o3 = al2o3.setScale(2, RoundingMode.HALF_UP);
                compressive = compressive.setScale(2, RoundingMode.HALF_UP);
                strength = strength.setScale(2, RoundingMode.HALF_UP);

                // 构造一个唯一的键
                String key = model + "-" + region + "-" + strength + "-" + cao + "-" + sio2 + "-" + al2o3 + "-" + compressive;

                // 判断是否存在该记录
                if (sysCementMap.containsKey(key)) {
                    System.out.println("记录已存在（字段完全相同），跳过插入: " + record);
                    continue;
                }

                // 创建 SysCement 对象并加入临时列表
                SysCement sysCement = new SysCement();
                sysCement.setModel(model);
                sysCement.setRegionName(region);
                sysCement.setStrengthGrade(strength);
                sysCement.setCaoContent(cao);
                sysCement.setSio2Content(sio2);
                sysCement.setAl2o3Content(al2o3);
                sysCement.setCompressiveStrength28d(compressive);
                sysCement.setCreateTime(Timestamp.valueOf(LocalDateTime.now()));
                sysCement.setId(IdUtils.generateRandomNumber());
                batchInsertList.add(sysCement);

            } catch (Exception e) {
                e.printStackTrace();
                System.err.println("插入数据失败: " + record);
            }
        }

        // 批量插入数据
        if (!batchInsertList.isEmpty()) {
            boolean batchInsertSuccess = sysCementService.saveBatch(batchInsertList);
            if (batchInsertSuccess) {
                successfulInserts = batchInsertList.size();  // 批量插入的成功条数
            } else {
                System.err.println("批量插入失败");
            }
        }

        // 更新审核状态（无论插入成功与否）
        updateAuditStatus(id, status);

        if (successfulInserts > 0) {
            return AjaxResult.success("审核通过，插入水泥数据成功，成功条数: " + successfulInserts);
        } else {
            return AjaxResult.success("审核通过，但所有数据已存在，未插入新数据");
        }
    }


    /*粉煤灰插入校验*/
    private AjaxResult saveSysFlyash(String filePath, String id, Integer status) {
        ObjectMapper objectMapper = new ObjectMapper();
        List<List<String>> data;
        try {
            // 检查文件是否存在
            File jsonFile = new File(filePath);
            if (!jsonFile.exists()) {
                return AjaxResult.error("文件不存在: " + filePath);
            }

            // 解析 JSON 文件为二维数组（每一行是一条水泥记录）
            data = objectMapper.readValue(jsonFile, new com.fasterxml.jackson.core.type.TypeReference<List<List<String>>>() {
            });
        } catch (IOException e) {
            e.printStackTrace();
            return AjaxResult.error("JSON 文件解析失败: " + e.getMessage());
        }

        int successfulInserts = 0;

        // 获取所有已存在的水泥记录并存储在一个集合中
        LambdaQueryWrapper<SysFlyash> wrapper = new LambdaQueryWrapper<>();
        List<SysFlyash> list = sysFlyashService.list(wrapper);
        Map<String, SysFlyash> sysCementMap = new HashMap<>();

        for (SysFlyash sysCement : list) {
            String key = sysCement.getGrade() + "-" + sysCement.getFactoryGrade() + "-" + sysCement.getFineness() +
                    "-" + sysCement.getMoistureContent() + "-" + sysCement.getActivityIndex28d() + "-" + sysCement.getRegionName();
            sysCementMap.put(key, sysCement);  // 使用一个唯一的组合键作为 map 的 key
        }

        // 创建一个临时列表，用于存储要插入的数据
        List<SysFlyash> batchInsertList = new ArrayList<>();

        // 遍历每条水泥数据
        for (List<String> record : data) {
            if (record.size() != 6) {
                System.err.println("无效数据格式: " + record);
                continue;
            }

            try {
                // 解析数据
                String model = record.get(0);//型号
                String factoryGrade = record.get(1);//出厂等级

                BigDecimal fineness = new BigDecimal(record.get(2));//细度(%)
                BigDecimal moistureContent = new BigDecimal(record.get(3));//含水量
                BigDecimal activityIndex28d = new BigDecimal(record.get(4));//28天活性指数(%)
                int regionName = Integer.parseInt(record.get(5));//来源地区

                // 确保所有 BigDecimal 保留两位小数
                fineness = fineness.setScale(2, RoundingMode.HALF_UP);
                moistureContent = moistureContent.setScale(2, RoundingMode.HALF_UP);
                activityIndex28d = activityIndex28d.setScale(2, RoundingMode.HALF_UP);
                // 构造一个唯一的键
                String key = model + "-" + factoryGrade + "-" + fineness + "-" + moistureContent + "-" + activityIndex28d + "-" + regionName;

                // 判断是否存在该记录
                if (sysCementMap.containsKey(key)) {
                    System.out.println("记录已存在（字段完全相同），跳过插入: " + record);
                    continue;
                }

                SysFlyash sysFlyash = new SysFlyash();
                sysFlyash.setGrade(model);
                sysFlyash.setFactoryGrade(factoryGrade);
                sysFlyash.setFineness(fineness);
                sysFlyash.setMoistureContent(moistureContent);
                sysFlyash.setActivityIndex28d(activityIndex28d);
                sysFlyash.setRegionName(regionName);
                sysFlyash.setCreateTime(Timestamp.valueOf(LocalDateTime.now()));
                sysFlyash.setId(IdUtils.generateRandomNumber());
                // 创建 SysCement 对象并加入临时列表

                batchInsertList.add(sysFlyash);

            } catch (Exception e) {
                e.printStackTrace();
                System.err.println("插入数据失败: " + record);
            }
        }

        // 批量插入数据
        if (!batchInsertList.isEmpty()) {
            boolean batchInsertSuccess = sysFlyashService.saveBatch(batchInsertList);
            if (batchInsertSuccess) {
                successfulInserts = batchInsertList.size();  // 批量插入的成功条数
            } else {
                System.err.println("批量插入失败");
            }
        }

        // 更新审核状态（无论插入成功与否）
        updateAuditStatus(id, status);

        if (successfulInserts > 0) {
            return AjaxResult.success("审核通过，插入水泥数据成功，成功条数: " + successfulInserts);
        } else {
            return AjaxResult.success("审核通过，但所有数据已存在，未插入新数据");
        }
    }


    /**
     * 构造唯一 key，避免因 null、空格或精度问题导致的重复插入
     */
    /*减水剂插入校验*/
    private AjaxResult saveSysWaterReducer(String filePath, String id, Integer status) {
        ObjectMapper objectMapper = new ObjectMapper();
        List<List<String>> data;
        try {
            // 检查文件是否存在
            File jsonFile = new File(filePath);
            if (!jsonFile.exists()) {
                return AjaxResult.error("文件不存在: " + filePath);
            }

            // 解析 JSON 文件为二维数组（每一行是一条水泥记录）
            data = objectMapper.readValue(jsonFile, new com.fasterxml.jackson.core.type.TypeReference<List<List<String>>>() {
            });
        } catch (IOException e) {
            e.printStackTrace();
            return AjaxResult.error("JSON 文件解析失败: " + e.getMessage());
        }

        int successfulInserts = 0;

        // 获取所有已存在的水泥记录并存储在一个集合中
        LambdaQueryWrapper<SysWaterReducer> wrapper = new LambdaQueryWrapper<>();
        List<SysWaterReducer> list = sysWaterReducerService.list(wrapper);
        Map<String, SysWaterReducer> sysCementMap = new HashMap<>();
        System.out.println("list" + list);
        for (SysWaterReducer sysCement : list) {
            String key = sysCement.getModel() + "-" + sysCement.getSolidContent() + "-" +
                    sysCement.getCementPasteFlow() + "-" + sysCement.getReducingRate() + "-" +
                    sysCement.getSourceName();
            sysCementMap.put(key, sysCement);  // 使用一个唯一的组合键作为 map 的 key
        }

        System.out.println("sysCementMap" + sysCementMap);
        // 创建一个临时列表，用于存储要插入的数据
        List<SysWaterReducer> batchInsertList = new ArrayList<>();

        // 遍历每条水泥数据
        for (List<String> record : data) {
            if (record.size() != 7) {
                System.err.println("无效数据格式: " + record);
                continue;
            }

            try {
                // 解析数据
                String model = record.get(0);//型号


                BigDecimal solidContent = new BigDecimal(record.get(1));//含固量(%)
                BigDecimal cementPasteFlow = new BigDecimal(record.get(2));//水泥净浆流动度(mm)
                BigDecimal reducingRate = new BigDecimal(record.get(3));//减水率
                String regionName = record.get(4);//来源地区

                String photo1 = record.get(5);//来源地区
                String photo2 = record.get(6);//来源地区


                // 确保所有 BigDecimal 保留两位小数
                solidContent = solidContent.setScale(2, RoundingMode.HALF_UP);
                cementPasteFlow = cementPasteFlow.setScale(2, RoundingMode.HALF_UP);
                reducingRate = reducingRate.setScale(2, RoundingMode.HALF_UP);
                // 构造一个唯一的键
                String key = model + "-" + solidContent + "-" + cementPasteFlow + "-" + reducingRate + "-" + regionName;
                System.out.println("key" + key);
                // 判断是否存在该记录
                if (sysCementMap.containsKey(key)) {
                    System.out.println("记录已存在（字段完全相同），跳过插入: " + record);
                    continue;
                }

                SysWaterReducer sysWaterReducer = new SysWaterReducer();

                sysWaterReducer.setPhotoFirst(photo1);
                sysWaterReducer.setPhotoSecond(photo2);

                sysWaterReducer.setModel(model);
                sysWaterReducer.setSolidContent(solidContent);
                sysWaterReducer.setCementPasteFlow(cementPasteFlow);
                sysWaterReducer.setReducingRate(reducingRate);
                sysWaterReducer.setSourceName(regionName);

                sysWaterReducer.setCreateTime(Timestamp.valueOf(LocalDateTime.now()));
                sysWaterReducer.setId(IdUtils.generateRandomNumber());
                batchInsertList.add(sysWaterReducer);

            } catch (Exception e) {
                e.printStackTrace();
                System.err.println("插入数据失败: " + record);
            }
        }

        // 批量插入数据
        if (!batchInsertList.isEmpty()) {
            boolean batchInsertSuccess = sysWaterReducerService.saveBatch(batchInsertList);
            if (batchInsertSuccess) {
                successfulInserts = batchInsertList.size();  // 批量插入的成功条数
            } else {
                System.err.println("批量插入失败");
            }
        }

        // 更新审核状态（无论插入成功与否）
        updateAuditStatus(id, status);

        if (successfulInserts > 0) {
            return AjaxResult.success("审核通过，插入水泥数据成功，成功条数: " + successfulInserts);
        } else {
            return AjaxResult.success("审核通过，但所有数据已存在，未插入新数据");
        }
    }


    /*增效剂校验*/
    private AjaxResult saveSysEfficiencyAgent(String filePath, String id, Integer status) {
        ObjectMapper objectMapper = new ObjectMapper();
        List<List<String>> data;
        try {
            // 检查文件是否存在
            File jsonFile = new File(filePath);
            if (!jsonFile.exists()) {
                return AjaxResult.error("文件不存在: " + filePath);
            }

            // 解析 JSON 文件为二维数组（每一行是一条水泥记录）
            data = objectMapper.readValue(jsonFile, new com.fasterxml.jackson.core.type.TypeReference<List<List<String>>>() {
            });
        } catch (IOException e) {
            e.printStackTrace();
            return AjaxResult.error("JSON 文件解析失败: " + e.getMessage());
        }

        int successfulInserts = 0;

        // 获取所有已存在的水泥记录并存储在一个集合中
        LambdaQueryWrapper<SysEfficiencyAgent> wrapper = new LambdaQueryWrapper<>();
        List<SysEfficiencyAgent> list = sysEfficiencyAgentService.list(wrapper);
        Map<String, SysEfficiencyAgent> sysCementMap = new HashMap<>();
        System.out.println("list" + list);

        for (SysEfficiencyAgent sysCement : list) {
            String key = sysCement.getModel() + "-" + sysCement.getSourceName();
            sysCementMap.put(key, sysCement);  // 使用一个唯一的组合键作为 map 的 key
        }

        System.out.println("sysCementMap" + sysCementMap);

        // 创建一个临时列表，用于存储要插入的数据
        List<SysEfficiencyAgent> batchInsertList = new ArrayList<>();

        // 遍历每条水泥数据
        for (List<String> record : data) {
            if (record.size() != 2) {
                System.err.println("无效数据格式: " + record);
                continue;
            }

            try {
                // 解析数据
                String model = record.get(0);//型号
                String regionName = record.get(1);//来源地区


                // 构造一个唯一的键
                String key = model + "-" + regionName;
                System.out.println("哈哈哈key" + key);
                // 判断是否存在该记录
                if (sysCementMap.containsKey(key)) {
                    System.out.println("记录已存在（字段完全相同），跳过插入: " + record);
                    continue;
                }


                SysEfficiencyAgent sysEfficiencyAgent = new SysEfficiencyAgent();
                sysEfficiencyAgent.setModel(model);
                sysEfficiencyAgent.setSourceName(regionName);
                sysEfficiencyAgent.setCreateTime(Timestamp.valueOf(LocalDateTime.now()));
                sysEfficiencyAgent.setDeleteTime(0);
                sysEfficiencyAgent.setId(IdUtils.generateRandomNumber());
                batchInsertList.add(sysEfficiencyAgent);

            } catch (Exception e) {
                e.printStackTrace();
                System.err.println("插入数据失败: " + record);
            }
        }

        // 批量插入数据
        if (!batchInsertList.isEmpty()) {
            boolean batchInsertSuccess = sysEfficiencyAgentService.saveBatch(batchInsertList);
            if (batchInsertSuccess) {
                successfulInserts = batchInsertList.size();  // 批量插入的成功条数
            } else {
                System.err.println("批量插入失败");
            }
        }

        // 更新审核状态（无论插入成功与否）
        updateAuditStatus(id, status);

        if (successfulInserts > 0) {
            return AjaxResult.success("审核通过，插入水泥数据成功，成功条数: " + successfulInserts);
        } else {
            return AjaxResult.success("审核通过，但所有数据已存在，未插入新数据");
        }
    }


    /*插入膨胀剂*/
    private AjaxResult saveSysSwellingagent(String filePath, String id, Integer status) {
        ObjectMapper objectMapper = new ObjectMapper();
        List<List<String>> data;
        try {
            // 检查文件是否存在
            File jsonFile = new File(filePath);
            if (!jsonFile.exists()) {
                return AjaxResult.error("文件不存在: " + filePath);
            }

            // 解析 JSON 文件为二维数组（每一行是一条水泥记录）
            data = objectMapper.readValue(jsonFile, new com.fasterxml.jackson.core.type.TypeReference<List<List<String>>>() {
            });
        } catch (IOException e) {
            e.printStackTrace();
            return AjaxResult.error("JSON 文件解析失败: " + e.getMessage());
        }

        int successfulInserts = 0;

        // 获取所有已存在的水泥记录并存储在一个集合中
        LambdaQueryWrapper<SysSwellingagent> wrapperSwellingagent = new LambdaQueryWrapper<>();
        List<SysSwellingagent> list = sysSwellingagentService.list(wrapperSwellingagent);
        Map<String, SysSwellingagent> sysCementMap = new HashMap<>();
        System.out.println("list" + list);

        for (SysSwellingagent sysCement : list) {
            String key = sysCement.getModel() + "-" + sysCement.getSourceName();
            sysCementMap.put(key, sysCement);  // 使用一个唯一的组合键作为 map 的 key
        }


        System.out.println("sysCementMap" + sysCementMap);

        // 创建一个临时列表，用于存储要插入的数据
        List<SysSwellingagent> batchInsertList = new ArrayList<>();

        // 遍历每条水泥数据
        for (List<String> record : data) {
            if (record.size() != 2) {
                System.err.println("无效数据格式: " + record);
                continue;
            }

            try {
                // 解析数据
                String model = record.get(0);//型号
                String regionName = record.get(1);//来源地区


                // 构造一个唯一的键
                String key = model + "-" + regionName;
                System.out.println("哈哈哈key" + key);
                // 判断是否存在该记录
                if (sysCementMap.containsKey(key)) {
                    System.out.println("记录已存在（字段完全相同），跳过插入: " + record);
                    continue;
                }

                SysSwellingagent sysSwellingagent = new SysSwellingagent();

                sysSwellingagent.setModel(model);
                sysSwellingagent.setSourceName(regionName);
                sysSwellingagent.setCreateTime(Timestamp.valueOf(LocalDateTime.now()));
                sysSwellingagent.setDeleteTime(0);
                sysSwellingagent.setId(IdUtils.generateRandomNumber());
                batchInsertList.add(sysSwellingagent);

            } catch (Exception e) {
                e.printStackTrace();
                System.err.println("插入数据失败: " + record);
            }
        }

        // 批量插入数据
        if (!batchInsertList.isEmpty()) {
            boolean batchInsertSuccess = sysSwellingagentService.saveBatch(batchInsertList);
            if (batchInsertSuccess) {
                successfulInserts = batchInsertList.size();  // 批量插入的成功条数
            } else {
                System.err.println("批量插入失败");
            }
        }

        // 更新审核状态（无论插入成功与否）
        updateAuditStatus(id, status);

        if (successfulInserts > 0) {
            return AjaxResult.success("审核通过，插入增效剂数据成功，成功条数: " + successfulInserts);
        } else {
            return AjaxResult.success("审核通过，但所有数据已存在，未插入新数据");
        }
    }


    /*矿粉插入校验*/
    private AjaxResult saveSysMineralPowder(String filePath, String id, Integer status) {
        ObjectMapper objectMapper = new ObjectMapper();
        List<List<String>> data;
        try {
            // 检查文件是否存在
            File jsonFile = new File(filePath);
            if (!jsonFile.exists()) {
                return AjaxResult.error("文件不存在: " + filePath);
            }

            // 解析 JSON 文件为二维数组（每一行是一条水泥记录）
            data = objectMapper.readValue(jsonFile, new com.fasterxml.jackson.core.type.TypeReference<List<List<String>>>() {
            });
        } catch (IOException e) {
            e.printStackTrace();
            return AjaxResult.error("JSON 文件解析失败: " + e.getMessage());
        }

        int successfulInserts = 0;

        // 获取所有已存在的水泥记录并存储在一个集合中
        LambdaQueryWrapper<SysMineralPowder> wrapper = new LambdaQueryWrapper<>();
        List<SysMineralPowder> list = sysMineralPowderService.list(wrapper);
        Map<String, SysMineralPowder> sysCementMap = new HashMap<>();

        for (SysMineralPowder sysCement : list) {
            String key = sysCement.getModel() + "-" + sysCement.getSlagGrade() + "-" + sysCement.getFineness() +
                    "-" + sysCement.getMoistureContent() + "-" + sysCement.getActivityIndex28d() + "-" + sysCement.getRegionName();
            sysCementMap.put(key, sysCement);  // 使用一个唯一的组合键作为 map 的 key
        }

        // 创建一个临时列表，用于存储要插入的数据
        List<SysMineralPowder> batchInsertList = new ArrayList<>();

        // 遍历每条水泥数据
        for (List<String> record : data) {
            if (record.size() != 6) {
                System.err.println("无效数据格式: " + record);
                continue;
            }

            try {
                // 解析数据
                String model = record.get(0);//型号
                String slagGrade = record.get(1);//矿粉等级

                BigDecimal fineness = new BigDecimal(record.get(2));//细度(%)
                BigDecimal moistureContent = new BigDecimal(record.get(3));//含水量
                BigDecimal activityIndex28d = new BigDecimal(record.get(4));//28天活性指数(%)
                int regionName = Integer.parseInt(record.get(5));//来源地区

                // 确保所有 BigDecimal 保留两位小数
                fineness = fineness.setScale(2, RoundingMode.HALF_UP);
                moistureContent = moistureContent.setScale(2, RoundingMode.HALF_UP);
                activityIndex28d = activityIndex28d.setScale(2, RoundingMode.HALF_UP);
                // 构造一个唯一的键
                String key = model + "-" + slagGrade + "-" + fineness + "-" + moistureContent + "-" + activityIndex28d + "-" + regionName;

                // 判断是否存在该记录
                if (sysCementMap.containsKey(key)) {
                    System.out.println("记录已存在（字段完全相同），跳过插入: " + record);
                    continue;
                }


                SysMineralPowder powder = new SysMineralPowder();
                powder.setModel(model);
                powder.setSlagGrade(slagGrade);
                powder.setFineness(fineness);
                powder.setMoistureContent(moistureContent);
                powder.setActivityIndex28d(activityIndex28d);
                powder.setRegionName(regionName);
                powder.setCreateTime(Timestamp.valueOf(LocalDateTime.now()));

                // 创建 SysCement 对象并加入临时列表
                batchInsertList.add(powder);

            } catch (Exception e) {
                e.printStackTrace();
                System.err.println("插入数据失败: " + record);
            }
        }

        // 批量插入数据
        if (!batchInsertList.isEmpty()) {
            boolean batchInsertSuccess = sysMineralPowderService.saveBatch(batchInsertList);
            if (batchInsertSuccess) {
                successfulInserts = batchInsertList.size();  // 批量插入的成功条数
            } else {
                System.err.println("批量插入失败");
            }
        }

        // 更新审核状态（无论插入成功与否）
        updateAuditStatus(id, status);

        if (successfulInserts > 0) {
            return AjaxResult.success("审核通过，插入水泥数据成功，成功条数: " + successfulInserts);
        } else {
            return AjaxResult.success("审核通过，但所有数据已存在，未插入新数据");
        }
    }


    /*石粉校验*/
    private AjaxResult saveSysOtherAdmixtures(String filePath, String id, Integer status) {
        ObjectMapper objectMapper = new ObjectMapper();
        List<List<String>> data;
        try {
            // 检查文件是否存在
            File jsonFile = new File(filePath);
            if (!jsonFile.exists()) {
                return AjaxResult.error("文件不存在: " + filePath);
            }

            // 解析 JSON 文件为二维数组（每一行是一条水泥记录）
            data = objectMapper.readValue(jsonFile, new com.fasterxml.jackson.core.type.TypeReference<List<List<String>>>() {
            });
        } catch (IOException e) {
            e.printStackTrace();
            return AjaxResult.error("JSON 文件解析失败: " + e.getMessage());
        }

        int successfulInserts = 0;

        // 获取所有已存在的水泥记录并存储在一个集合中
        LambdaQueryWrapper<SysOtherAdmixtures> wrapper = new LambdaQueryWrapper<>();
        List<SysOtherAdmixtures> list = sysOtherAdmixturesService.list(wrapper);
        Map<String, SysOtherAdmixtures> sysCementMap = new HashMap<>();
        System.out.println("sysCementMap" + sysCementMap);
        for (SysOtherAdmixtures sysCement : list) {
            String key = sysCement.getModel() + "-" + sysCement.getFineness() +
                    "-" + sysCement.getMoistureContent() + "-" + sysCement.getActivityIndex28d() + "-" + sysCement.getRegionName();

            sysCementMap.put(key, sysCement);  // 使用一个唯一的组合键作为 map 的 key
        }

        // 创建一个临时列表，用于存储要插入的数据
        List<SysOtherAdmixtures> batchInsertList = new ArrayList<>();

        // 遍历每条水泥数据
        for (List<String> record : data) {
            if (record.size() != 5) {
                System.err.println("无效数据格式: " + record);
                continue;
            }

            try {
                // 解析数据
                String model = record.get(0);//型号

                BigDecimal fineness = new BigDecimal(record.get(1));//细度
                BigDecimal moistureContent = new BigDecimal(record.get(2));//含水量
                BigDecimal activityIndex28d = new BigDecimal(record.get(3));//28天活性指数(%)

                int regionName = Integer.parseInt(record.get(4));//来源地区

                // 确保所有 BigDecimal 保留两位小数
                fineness = fineness.setScale(2, RoundingMode.HALF_UP);
                moistureContent = moistureContent.setScale(2, RoundingMode.HALF_UP);
                activityIndex28d = activityIndex28d.setScale(2, RoundingMode.HALF_UP);

                // 构造一个唯一的键
                String key = model + "-" + fineness + "-" + moistureContent + "-" + activityIndex28d + "-" + regionName;
                System.out.println("key" + key);
                // 判断是否存在该记录
                if (sysCementMap.containsKey(key)) {
                    System.out.println("记录已存在（字段完全相同），跳过插入: " + record);
                    continue;
                }


                SysOtherAdmixtures sysOtherAdmixtures = new SysOtherAdmixtures();
                sysOtherAdmixtures.setModel(model);
                sysOtherAdmixtures.setFineness(fineness);
                sysOtherAdmixtures.setMoistureContent(moistureContent);
                sysOtherAdmixtures.setActivityIndex28d(activityIndex28d);
                sysOtherAdmixtures.setRegionName(regionName);
                sysOtherAdmixtures.setCreateTime(Timestamp.valueOf(LocalDateTime.now()));

                // 创建 SysCement 对象并加入临时列表
                batchInsertList.add(sysOtherAdmixtures);

            } catch (Exception e) {
                e.printStackTrace();
                System.err.println("插入数据失败: " + record);
            }
        }

        // 批量插入数据
        if (!batchInsertList.isEmpty()) {
            boolean batchInsertSuccess = sysOtherAdmixturesService.saveBatch(batchInsertList);
            if (batchInsertSuccess) {
                successfulInserts = batchInsertList.size();  // 批量插入的成功条数
            } else {
                System.err.println("批量插入失败");
            }
        }

        // 更新审核状态（无论插入成功与否）
        updateAuditStatus(id, status);

        if (successfulInserts > 0) {
            return AjaxResult.success("审核通过，插入水泥数据成功，成功条数: " + successfulInserts);
        } else {
            return AjaxResult.success("审核通过，但所有数据已存在，未插入新数据");
        }
    }


    //    private AjaxResult savewater(String filePath, String id, Integer status) {
//
//        ObjectMapper objectMapper = new ObjectMapper();
//        List<List<String>> data;
//
//        try {
//            // 检查文件是否存在
//            File jsonFile = new File(filePath);
//            if (!jsonFile.exists()) {
//                return AjaxResult.error("文件不存在: " + filePath);
//            }
//
//            // 解析 JSON 文件
//            data = objectMapper.readValue(jsonFile, new com.fasterxml.jackson.core.type.TypeReference<List<List<String>>>() {
//            });
//        } catch (IOException e) {
//            e.printStackTrace();
//            return AjaxResult.error("JSON 文件解析失败: " + e.getMessage());
//        }
//
//        int successfulInserts = 0;
//
//        // 遍历并处理每条记录
//        for (List<String> record : data) {
//            if (record.size() != 3) {
//                System.err.println("无效数据格式: " + record);
//                continue;
//            }
//
//            String grade = record.get(0);
//            String fineness = record.get(1);
//            String regionName = record.get(2);
//
//            try {
//
//                SysWater sysWater = new SysWater();
//
//                sysWater.setModel();
//                sysWater.se
//
//                // 插入粉煤灰数据
//                SysFlyash flyash = new SysFlyash();
//                flyash.setGrade(grade);
//                flyash.setFineness(BigDecimal.valueOf(Long.parseLong(fineness)));
//
//                flyash.setRegionName(regionId);
//                flyash.setCreateTime(Timestamp.valueOf(LocalDateTime.now()));
//
//                int insert = sysFlyashMapper.insert(flyash);
//                if (insert > 0) {
//                    successfulInserts++;
//                } else {
//                    System.err.println("粉煤灰数据插入失败: " + record);
//                }
//            } catch (Exception e) {
//                e.printStackTrace();
//                System.err.println("插入数据失败: " + record);
//            }
//        }
//
//        // 检查插入结果
//        if (successfulInserts > 0) {
//            updateAuditStatus(id, status);
//            return AjaxResult.success("审核通过，插入粉煤灰数据成功，成功条数: " + successfulInserts);
//        } else {
//            return AjaxResult.error("没有有效数据被插入");
//        }
//
//    }
//
//
    @Override
    public List<SysFileAudit> queryFileAuditByUserId(FileAuditDTO fileAuditDTO) {

        return sysFileAuditMapper.queryFileAuditByUserId(fileAuditDTO);
    }

    private void updateAuditStatus(String id, Integer status) {
        SysFileAudit fileAudit = new SysFileAudit();
        fileAudit.setStatus(status);

        LambdaQueryWrapper<SysFileAudit> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(SysFileAudit::getId, id);

        int updatedRows = sysFileAuditMapper.update(fileAudit, wrapper);
        if (updatedRows > 0) {
            System.out.println("审核状态更新成功, ID: " + id + ", 新状态: " + status);
        } else {
            System.err.println("审核状态更新失败, ID: " + id);
        }
    }


}